girzel / ebdb

An EIEIO port of BBDB, Emacs' contact-management package
67 stars 11 forks source link

Q: how can import a csv to ebdb ? #64

Closed eggcaker closed 6 years ago

eggcaker commented 6 years ago

Just have a question If I have a csv file with few fields, how can I import them to ebdb or only way i type by hand ?

girzel commented 6 years ago

Huh, I hadn't thought of that. I didn't realize that there were more-or-less regular formats for putting contacts in CSV files -- I just looked at bbdb-csv-import. I will put this on the list, though I'm afraid I won't get to it very soon. What program are you using to put your contacts into CSV format?

If you're comfortable with elisp, you could install the pcsv package, and use that to parse the file into elisp. Then create an EBDB database, and then for each contact name:

(let ((name (ebdb-parse 'ebdb-field-name-complex <name-string>))
      (rec (ebdb-record-person)))
  (ebdb-record-change-name rec name)
  (ebdb-db-add-record (car ebdb-db-list) rec)
  (ebdb-init-record rec))

If you've got phone and email fields, you can add them at the same time, with something like:

(ebdb-record-insert-field rec (ebdb-parse 'ebdb-field-mail <mail string>))

Replacing edb-field-mail with ebdb-field-phone for phones. Unfortunately that won't work for addresses, which is a bit of a pain.

I know that's not very helpful! But it's probably the best that can be done at the moment.

eggcaker commented 6 years ago

I tried the bbdb-csv-import yesterday, failed, some function not. compatible with ebdb, i am very new to emacs lisp but I will paly with that to me see if I can . Thank you.

girzel commented 6 years ago

bbdb and ebdb are completely different packages! They won't be compatible with one another.