lucc / khard

Console vcard client
https://khard.readthedocs.io/en/latest/
GNU General Public License v3.0
595 stars 66 forks source link

How to import contacts from existing databases? #287

Closed poetaman closed 1 year ago

poetaman commented 3 years ago

Can you please add steps needed to import contacts from existing databases? Am looking forward to import contacts from macOS in-built Contacts app. I can select all contacts, and export them as one "vcards" file. Not sure how to import it using Khard. I mean there should be an option to say khard --import <filename or directory_name>

lucc commented 3 years ago

As described in the docs you will need to have the contacts from your existing database in individual vcard files. One big file with many vcards is not supported.

If our underlying vobject library supports single files with many vcard objects inside an import function should be possible to implement. The import command could accept input in vcard format and normalize them (add a uid e.g.) as well as vaddressbook I would be open for pull requests.

There has been some discussion about this before: #252

jakeogh commented 2 years ago

https://github.com/jakeogh/vcardtool will split a multiple record vcf into individual files.

It vcardtool encounters VERSION:2.1 records (which cause the warning messages in #279) it suggests preprocessing the input file with https://github.com/jowave/vcard2to3.

vcardtool will also insert a UID field if necessary to address issue #288.

rogarb commented 1 year ago

As I was setting up khard for managing my email client contacts, I also faced the issue of splitting my vcf files, but before I could find this issue, I had written a python script to do it (vcf-splitter for the record).

My point is: shouldn't the docs be updated to mention some scripts for splitting existing vcf files? I can create a PR with a modified version of i.e. doc/source/scripting.rst referencing the tools mentioned in this issue.

lucc commented 1 year ago

@rogarb PR welcome!

lucc commented 1 year ago

@poetaman I will close this as #317 is merged.

If someone still needs a new subcommand in khard they can use vobject.readComponents and send a PR.