small doc update
[bbdb-csv-import] / bbdb-csv-import.el
1 ;;; bbdb-csv-import.el --- import csv to bbdb version 3+
2
3 ;; Copyright (C) 2014 by Ian Kelling
4
5 ;; Maintainer: Ian Kelling <ian@iankelling.org>
6 ;; Author: Ian Kelling <ian@iankelling.org>
7 ;; Created: 1 Apr 2014
8 ;; Version: 1.1
9 ;; Package-Requires: ((pcsv "1.3.3") (dash "2.5.0") (bbdb "20140412.1949"))
10 ;; Keywords: csv, util, bbdb
11 ;; Homepage: https://gitlab.com/iankelling/bbdb-csv-import
12 ;; Mailing-List: https://lists.iankelling.org/listinfo/bbdb-csv-import
13
14 ;; This program is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation, either version 3 of the License, or
17 ;; (at your option) any later version.
18
19 ;; This program is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
23
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
26
27 ;;; Commentary:
28 ;;
29 ;; Importer of csv (comma separated value) text into Emacs’s bbdb database,
30 ;; version 3+. Works out of the box with csv exported from Thunderbird, Gmail,
31 ;; Linkedin, Outlook.com/hotmail, and probably others.
32 ;; Easily extensible to handle new formats.
33
34 ;;; Installation:
35 ;;
36 ;; If you installed this file with a package manager, just
37 ;;
38 ;; (require 'bbdb-csv-import)
39 ;;
40 ;; Else, note the min versions of dependencies above in "Package-Requires:",
41 ;; and load this file. The exact minimum bbdb version is unknown, something 3+.
42 ;;
43 ;;; Basic Usage:
44 ;;
45 ;; Back up bbdb by copying `bbdb-file' in case things go wrong.
46 ;;
47 ;; Simply M-x `bbdb-csv-import-buffer' or `bbdb-csv-import-file'.
48 ;; When called interactively, they prompt for file or buffer arguments.
49 ;;
50 ;; Then view your bbdb records: M-x bbdb .* RET
51 ;; If the import looks good save the bbdb database: C-x s (bbdb-save)
52
53 ;;; Advanced usage / notes:
54 ;;
55 ;; Tested to work with thunderbird, gmail, linkedin,
56 ;; outlook.com/hotmail.com. For those programs, if it's exporter has an option
57 ;; of what kind of csv format, choose it's own native format if available, if
58 ;; not, choose an outlook compatible format. If you're exporting from some other
59 ;; program and its csv exporter claims outlook compatibility, there is a good
60 ;; chance it will work out of the box. If it doesn't, you can try to fix it as
61 ;; described below, or the maintainer will be happy to help, just anonymize your
62 ;; csv data using the M-x bbdb-csv-anonymize-current-buffer (make sure csv
63 ;; buffer is the current one) and attach it to an email to the mailing list.
64 ;;
65 ;; Duplicate contacts (according to email address) are skipped if
66 ;; bbdb-allow-duplicates is nil (default). Any duplicates found are echoed at
67 ;; the end of the import.
68
69 ;;; Custom mapping of csv fields
70 ;;
71 ;; If a field is handled wrong or you want to extend the program to handle a new
72 ;; kind of csv format, you need to setup a custom field mapping variable. Use
73 ;; the existing tables as an example. By default, we use a combination of most
74 ;; predefined mappings, and look for all of their fields, but it is probably
75 ;; best to avoid that kind of table when setting up your own as it is an
76 ;; unnecessary complexity in that case. If you have a problem with data from a
77 ;; supported export program, start by testing its specific mapping table instead
78 ;; of the combined one. Here is a handy template to set each of the predefined
79 ;; mapping tables if you would rather avoid the configure interface:
80 ;;
81 ;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-combined)
82 ;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-thunderbird)
83 ;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-gmail)
84 ;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-gmail-typed-email)
85 ;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-linkedin)
86 ;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-outlook-web)
87 ;; (setq bbdb-csv-import-mapping-table bbdb-csv-import-outlook-typed-email)
88 ;;
89 ;; The doc string for `bbdb-create-internal' may also be useful when creating a
90 ;; mapping table. If you create a table for a program not not already supported,
91 ;; please share it with the mailing list so it can be added to this program.
92 ;; The maintainer should be able to help with any issues and may create a new
93 ;; mapping table given sample data.
94 ;;
95 ;; Mapping table tips:
96 ;; * The repeat keyword expands numbered field names, based on the first
97 ;; field, as many times as they exist in the csv data.
98 ;; * All mapping fields are optional. A simple mapping table could be
99 ;; (setq bbdb-csv-import-mapping-table '((:mail "Primary Email")))
100 ;; * :xfields uses the csv field name to create custom fields in bbdb. It downcases
101 ;; the field name, and replaces spaces with "-", and repeating dashes with a
102 ;; single one . For example, if you had a csv named "Mail Alias" or "Mail - alias",
103 ;; you could add it to :xfields in a mapping table and it would become "mail-alias"
104 ;; in bbdb.
105
106 ;;; Misc tips/troubleshooting:
107 ;;
108 ;; - ASynK looks promising for syncing bbdb/google/outlook.
109 ;; - The git repo contains a test folder with exactly tested version info and working
110 ;; test data. Software, and especially online services are prone to changing how they
111 ;; export. Please send feedback if you run into problems.
112 ;; - bbdb doesn't work if you delete the bbdb database file in
113 ;; the middle of an emacs session. If you want to empty the current bbdb database,
114 ;; do M-x bbdb then .* then C-u * d on the beginning of a record.
115 ;; - After changing a mapping table variable, don't forget to re-execute
116 ;; (setq bbdb-csv-import-mapping-table ...) so that it propagates.
117 ;; - :namelist is used instead of :name if 2 or more non-empty fields from :namelist are
118 ;; found in a record. If :name is empty, we try a single non-empty field from :namelist
119 ;; This sounds a bit strange, but it's to try and deal with Thunderbird idiosyncrasies.
120
121 ;;; Bugs, patches, discussion, feedback
122 ;;
123 ;; Patches and bugs are very welcome via https://gitlab.com/iankelling/bbdb-csv-import
124 ;;
125 ;; Questions, feedback, or anything is very welcome at to the bbdb-csv-import mailing list
126 ;; https://lists.iankelling.org/listinfo/bbdb-csv-import, no subscription needed to post via
127 ;; bbdb-csv-import@lists.iankelling.org. The maintainer would probably be happy
128 ;; to work on new features if something is missing.
129
130
131
132 ;;; Code:
133 (require 'pcsv)
134 (require 'dash)
135 (require 'bbdb-com)
136 (eval-when-compile (require 'cl))
137
138 (defconst bbdb-csv-import-thunderbird
139 '((:namelist "First Name" "Last Name")
140 (:name "Display Name")
141 (:aka "Nickname")
142 (:mail "Primary Email" "Secondary Email")
143 (:phone "Work Phone" "Home Phone" "Fax Number" "Pager Number" "Mobile Number")
144 (:address
145 (("home address"
146 (("Home Address" "Home Address 2")
147 "Home City" "Home State"
148 "Home ZipCode" "Home Country"))
149 ("work address"
150 (("Work Address" "Work Address 2")
151 "Work City" "Work State"
152 "Work ZipCode" "Work Country"))))
153 (:organization "Organization")
154 (:xfields "Web Page 1" "Web Page 2" "Birth Year" "Birth Month"
155 "Birth Day" "Department" "Custom 1" "Custom 2" "Custom 3"
156 "Custom 4" "Notes" "Job Title"))
157 "Thunderbird csv format")
158
159 (defconst bbdb-csv-import-linkedin
160 '((:namelist "First Name" "Middle Name" "Last Name")
161 (:affix "Suffix")
162 (:mail "E-mail Address" "E-mail 2 Address" "E-mail 3 Address")
163 (:phone
164 "Assistant's Phone" "Business Fax" "Business Phone"
165 "Business Phone 2" "Callback" "Car Phone"
166 "Company Main Phone" "Home Fax" "Home Phone"
167 "Home Phone 2" "ISDN" "Mobile Phone"
168 "Other Fax" "Other Phone" "Pager"
169 "Primary Phone" "Radio Phone" "TTY/TDD Phone" "Telex")
170 (:address
171 (("business address"
172 (("Business Street" "Business Street 2" "Business Street 3")
173 "Business City" "Business State"
174 "Business Postal Code" "Business Country"))
175 ("home address"
176 (("Home Street" "Home Street 2" "Home Street 3")
177 "Home City" "Home State"
178 "Home Postal Code" "Home Country"))
179 ("other address"
180 (("Other Street" "Other Street 2" "Other Street 3")
181 "Other City" "Other State"
182 "Other Postal Code" "Other Country"))))
183 (:organization "Company")
184 (:xfields
185 "Department" "Job Title" "Assistant's Name"
186 "Birthday" "Manager's Name" "Notes" "Other Address PO Box"
187 "Spouse" "Web Page" "Personal Web Page"))
188 "Linkedin export in the Outlook csv format.")
189
190
191 (defconst bbdb-csv-import-gmail
192 '((:namelist "Given Name" "Family Name")
193 (:name "Name")
194 (:affix "Name Prefix" "Name Suffix")
195 (:aka "Nickname")
196 (:mail (repeat "E-mail 1 - Value"))
197 (:phone (repeat ("Phone 1 - Type" "Phone 1 - Value")))
198 (:address
199 (repeat (("Address 1 - Type")
200 (("Address 1 - Street" "Address 1 - PO Box" "Address 1 - Extended Address")
201 "Address 1 - City" "Address 1 - Region"
202 "Address 1 - Postal Code" "Address 1 - Country"))))
203 (:organization (repeat "Organization 1 - Name"))
204 (:xfields
205 "Additional Name" "Yomi Name" "Given Name Yomi"
206 "Additional Name Yomi" "Family Name Yomi"
207 "Initials" "Short Name" "Maiden Name" "Birthday"
208 "Gender" "Location" "Billing Information"
209 "Directory Server" "Mileage" "Occupation"
210 "Hobby" "Sensitivity" "Priority"
211 "Subject" "Notes" "Group Membership"
212 ;; Gmail wouldn't let me add more than 1 organization in its web interface,
213 ;; but no harm in looking for multiple since the field name implies the
214 ;; possibility.
215 (repeat
216 "Organization 1 - Type" "Organization 1 - Yomi Name"
217 "Organization 1 - Title" "Organization 1 - Department"
218 "Organization 1 - Symbol" "Organization 1 - Location"
219 "Organization 1 - Job Description")
220 (repeat ("Relation 1 - Type" "Relation 1 - Value"))
221 (repeat ("Website 1 - Type" "Website 1 - Value"))
222 (repeat ("Event 1 - Type" "Event 1 - Value"))
223 (repeat ("Custom Field 1 - Type" "Custom Field 1 - Value"))))
224 "Gmail csv export format. Note some fields don't map perfectly,
225 feel free to modify them as you wish. \"PO Box\" and \"Extended
226 Address\" are added as additional address street lines if they
227 exist. Some special name fields are made custom instead of put in
228 name, which gets a single string. We map Gmail's \"Name Prefix\"
229 and \"Name Suffix\" to bbdb's affix (a list of strings). We lose
230 the prefix/suffix label, but those are usually obvious.")
231
232
233 (defconst bbdb-csv-import-gmail-typed-email
234 (append (car (last bbdb-csv-import-gmail)) '((repeat "E-mail 1 - Type")))
235 "Like the first Gmail mapping, but use custom fields to store
236 Gmail's email labels. This is separate because I assume most
237 people don't use those labels and using the default labels
238 would create useless custom fields.")
239
240 (defconst bbdb-csv-import-outlook-web
241 '((:namelist "First Name" "Middle Name" "Last Name")
242 (:mail "E-mail Address" "E-mail 2 Address" "E-mail 3 Address")
243 (:affix "Suffix")
244 (:phone
245 "Assistant's Phone" "Business Fax" "Business Phone"
246 "Business Phone 2" "Callback" "Car Phone"
247 "Company Main Phone" "Home Fax" "Home Phone"
248 "Home Phone 2" "ISDN" "Mobile Phone"
249 "Other Fax" "Other Phone" "Pager"
250 "Primary Phone" "Radio Phone" "TTY/TDD Phone" "Telex")
251 (:address
252 (("business address"
253 (("Business Street")
254 "Business City" "Business State"
255 "Business Postal Code" "Business Country"))
256 ("home address"
257 (("Home Street")
258 "Home City" "Home State"
259 "Home Postal Code" "Home Country"))
260 ("other address"
261 (("Other Street")
262 "Other City" "Other State"
263 "Other Postal Code" "Other Country"))))
264 (:organization "Company")
265 (:xfields
266 "Anniversary" "Family Name Yomi" "Given Name Yomi"
267 "Department" "Job Title" "Birthday" "Manager's Name" "Notes"
268 "Spouse" "Web Page"))
269 "Hotmail.com, outlook.com, live.com, etc.
270 Based on 'Export for outlook.com and other services',
271 not the export for Outlook 2010 and 2013.")
272
273 (defconst bbdb-csv-import-outlook-typed-email
274 (append (car (last bbdb-csv-import-outlook-web)) '((repeat "E-mail 1 - Type")))
275 "Like bbdb-csv-import-gmail-typed-email, but for outlook-web.
276 Adds email labels as custom fields.")
277
278
279 (defun bbdb-csv-import-flatten1 (list)
280 "Flatten LIST by 1 level."
281 (--reduce-from (if (consp it)
282 (-concat acc it)
283 (-snoc acc it))
284 nil list))
285
286
287 (defun bbdb-csv-import-merge-map (root)
288 "Combine two root mappings for making a combined mapping."
289 (bbdb-csv-import-flatten1
290 (list root
291 (-distinct
292 (append
293 (cdr (assoc root bbdb-csv-import-thunderbird))
294 (cdr (assoc root bbdb-csv-import-linkedin))
295 (cdr (assoc root bbdb-csv-import-gmail))
296 (cdr (assoc root bbdb-csv-import-outlook-web)))))))
297
298
299 (defconst bbdb-csv-import-combined
300 (list
301 ;; manually combined for proper ordering
302 '(:namelist "First Name" "Given Name" "Middle Name" "Last Name" "Family Name")
303 (bbdb-csv-import-merge-map :name)
304 (bbdb-csv-import-merge-map :affix)
305 (bbdb-csv-import-merge-map :aka)
306 (bbdb-csv-import-merge-map :mail)
307 (bbdb-csv-import-merge-map :phone)
308 ;; manually combined the addresses. Because it was easier.
309 '(:address
310 (repeat (("Address 1 - Type")
311 (("Address 1 - Street" "Address 1 - PO Box" "Address 1 - Extended Address")
312 "Address 1 - City" "Address 1 - Region"
313 "Address 1 - Postal Code" "Address 1 - Country")))
314 (("business address"
315 (("Business Street" "Business Street 2" "Business Street 3")
316 "Business City" "Business State"
317 "Business Postal Code" "Business Country"))
318 ("home address"
319 (("Home Street" "Home Street 2" "Home Street 3"
320 "Home Address" "Home Address 2")
321 "Home City" "Home State"
322 "Home Postal Code" "Home ZipCode" "Home Country"))
323 ("work address"
324 (("Work Address" "Work Address 2")
325 "Work City" "Work State"
326 "Work ZipCode" "Work Country"))
327 ("other address"
328 (("Other Street" "Other Street 2" "Other Street 3")
329 "Other City" "Other State"
330 "Other Postal Code" "Other Country"))))
331 (bbdb-csv-import-merge-map :organization)
332 (bbdb-csv-import-merge-map :xfields)))
333
334 (defcustom bbdb-csv-import-mapping-table bbdb-csv-import-combined
335 "The table which maps bbdb fields to csv fields. The default should work for most cases.
336 See the commentary section of this file for more details."
337 :group 'bbdb-csv-import
338 :type 'symbol)
339
340
341 (defun bbdb-csv-import-expand-repeats (csv-fields list)
342 "Return new list where elements from LIST in form (repeat elem1
343 ...) become ((elem1 ...) [(elem2 ...)] ...) for as many fields
344 exist in the csv fields. elem can be a string or a tree (a list
345 with lists inside it). We use the first element as a template,
346 and increase its number by one, and check if it exists, and then
347 increment any other elements from the repeat list which have
348 numbers in them."
349 (cl-flet ((replace-num (num string)
350 ;; in STRING, replace all groups of numbers with NUM
351 (replace-regexp-in-string "[0-9]+"
352 (number-to-string num)
353 string)))
354 (--reduce-from
355 (if (not (and (consp it) (eq (car it) 'repeat)))
356 (cons it acc)
357 (setq it (cdr it))
358 (let* ((i 1)
359 (first-field (car (-flatten it))))
360 (setq acc (cons it acc))
361 ;; use first-field to test if there is another repetition.
362 (while (member
363 (replace-num (setq i (1+ i)) first-field)
364 csv-fields)
365 (cl-labels ((fun (cell)
366 (if (consp cell)
367 (mapcar #'fun cell)
368 (replace-num i cell))))
369 (setq acc (cons (fun it) acc))))
370 acc))
371 nil list)))
372
373 (defun bbdb-csv-import-map-bbdb (csv-fields root)
374 "ROOT is a root element from bbdb-csv-import-mapping-table. Get
375 the csv-fields for root in the mapping format, including variably
376 repeated ones. Flatten by one because repeated fields are put in
377 sub-lists, but after expanding them, that extra depth is no
378 longer useful. Small trade off: address mappings without 'repeat need
379 to be grouped in a list because they contain sublists that we
380 don't want flattened."
381 (bbdb-csv-import-flatten1
382 (bbdb-csv-import-expand-repeats
383 csv-fields
384 (cdr (assoc root bbdb-csv-import-mapping-table)))))
385
386 ;;;###autoload
387 (defun bbdb-csv-import-file (filename)
388 "Parse and import csv file FILENAME to bbdb.
389 The file will be saved to disk with blank lines and aberrant characters removed."
390 (interactive "fCSV file containg contact data: ")
391 (bbdb-csv-import-buffer (find-file-noselect filename)))
392
393 ;;;###autoload
394 (defun bbdb-csv-import-buffer (&optional buffer-or-name)
395 "Parse and import csv buffer to bbdb. Interactively, it prompts for a buffer.
396 The buffer will be saved to disk with blank lines and aberrant characters removed.
397 BUFFER-OR-NAME is a buffer or name of a buffer, or the current buffer if nil."
398 (interactive "bBuffer containing CSV contact data: ")
399 (when (null bbdb-csv-import-mapping-table)
400 (error "error: `bbdb-csv-import-mapping-table' is nil. Please set it and rerun."))
401 (let* ((csv-buffer (get-buffer (or buffer-or-name (current-buffer))))
402 (csv-data (save-excursion
403 (set-buffer csv-buffer)
404 ;; deal with blank lines and ^M from linkedin
405 (flush-lines "^\\s-*$")
406 (goto-char (point-min))
407 ;; remove ^M aka ret characters
408 (while (re-search-forward (char-to-string 13) nil t)
409 (replace-match ""))
410 (basic-save-buffer)
411 (pcsv-parse-file buffer-file-name)))
412 (csv-fields (car csv-data))
413 (csv-data (cdr csv-data))
414 (allow-dupes bbdb-allow-duplicates)
415 csv-record rd assoc-plus map-bbdb dupes)
416 ;; convenient function names
417 (fset 'rd 'bbdb-csv-import-rd)
418 (fset 'assoc-plus 'bbdb-csv-import-assoc-plus)
419 (fset 'map-bbdb (-partial 'bbdb-csv-import-map-bbdb csv-fields))
420 ;; we handle duplicates ourselves
421 (setq bbdb-allow-duplicates t)
422 ;; loop over the csv records
423 (while (setq csv-record (map 'list 'cons csv-fields (pop csv-data)))
424 (cl-flet*
425 ((ca (key list) (cdr (assoc key list))) ;; utility function
426 (rd-assoc (root)
427 ;; given ROOT, return a list of data, ignoring empty fields
428 (rd (lambda (elem) (assoc-plus elem csv-record)) (map-bbdb root)))
429 (assoc-expand (e)
430 ;; E = data-field-name | (field-name-field data-field)
431 ;; get data from the csv-record and return (field-name data) or nil.
432 (let ((data-name (if (consp e) (ca (car e) csv-record) e))
433 (data (assoc-plus (if (consp e) (cadr e) e) csv-record)))
434 (if data (list data-name data)))))
435 ;; set the arguments to bbdb-create-internal, then call it, the end.
436 (let ((name (let ((namelist (rd-assoc :namelist))
437 (let-name (car (rd-assoc :name))))
438 ;; priority: 2 or more from :namelist, then non-empty :name, then
439 ;; any single element of :namelist
440 (cond ((>= (length namelist) 2)
441 (mapconcat 'identity namelist " "))
442 ((not (null let-name))
443 let-name)
444 (t
445 (mapconcat 'identity namelist " ")))))
446 (affix (rd-assoc :affix))
447 (aka (rd-assoc :aka))
448 (organization (rd-assoc :organization))
449 (mail (rd-assoc :mail))
450 (phone (rd 'vconcat (rd #'assoc-expand (map-bbdb :phone))))
451 (address (rd (lambda (e)
452
453 (let ((al (rd (lambda (elem) ;; al = address lines
454 (assoc-plus elem csv-record))
455 (caadr e)))
456 ;; to use bbdb-csv-import-combined, we can't mapcar
457 (address-data (--reduce-from (if (member it csv-fields)
458 (cons (ca it csv-record) acc)
459 acc)
460 nil (cdadr e)))
461 (elem-name (car e)))
462 (setq al (nreverse al))
463 (setq address-data (nreverse address-data))
464 ;; make it a list of at least 2 elements
465 (setq al (append al
466 (-repeat (- 2 (length al)) "")))
467 (when (consp elem-name)
468 (setq elem-name (ca (car elem-name) csv-record)))
469
470 ;; determine if non-nil and put together the minimum set
471 (when (or (not (--all? (zerop (length it)) address-data))
472 (not (--all? (zerop (length it)) al)))
473 (when (> 2 (length al))
474 (setcdr (max 2 (nthcdr (--find-last-index (not (null it))
475 al)
476 al)) nil))
477 (vconcat (list elem-name) (list al) address-data))))
478 (map-bbdb :address)))
479 (xfields (rd (lambda (list)
480 (let ((e (car list)))
481 (while (string-match " +" e)
482 (setq e (replace-match "-" nil nil e)))
483 (while (string-match "--+" e)
484 (setq e (replace-match "-" nil nil e)))
485 (setq e (make-symbol (downcase e)))
486 (cons e (cadr list)))) ;; change from (a b) to (a . b)
487 (rd #'assoc-expand (map-bbdb :xfields)))))
488 ;; we copy and subvert bbdb's duplicate detection instead of catching
489 ;; errors so that we don't interfere with other errors, and can print
490 ;; them nicely at the end.
491 (let (found-dupe)
492 (dolist (elt mail)
493 (when (bbdb-gethash elt '(mail))
494 (push elt dupes)
495 (setq found-dupe t)))
496 (when (or allow-dupes (not found-dupe))
497 (bbdb-create-internal name affix aka organization mail phone address xfields t))))))
498 (when dupes (if allow-dupes
499 (message "Warning, contacts with duplicate email addresses were imported:\n%s" dupes)
500 (message "Skipped contacts with duplicate email addresses:\n%s" dupes)))
501 (setq bbdb-allow-duplicates allow-dupes)))
502
503 (defun bbdb-csv-import-rd (func list)
504 "like mapcar but don't build nil results into the resulting list"
505 (--reduce-from (let ((funcreturn (funcall func it)))
506 (if funcreturn
507 (cons funcreturn acc)
508 acc))
509 nil list))
510
511 (defun bbdb-csv-import-assoc-plus (key list)
512 "Like (cdr assoc ...) but turn an empty string result to nil."
513 (let ((result (cdr (assoc key list))))
514 (when (not (string= "" result))
515 result)))
516
517 (defun bbdb-csv-anonymize-current-buffer ()
518 (interactive)
519 "Anonymize the current buffer which contains csv data.
520 The first line should contain header names."
521 (goto-line 2)
522 (while (re-search-forward "\\w")
523 (delete-char -1)
524 (insert (number-to-string (random 9)))))
525
526
527 (provide 'bbdb-csv-import)
528
529 ;;; bbdb-csv-import.el ends here