This project is a proof of concept for integrating and synchronizing contact information between Nextcloud address books and a local CSV file. The script fetches contacts from Nextcloud, merges the data to a CSV file with mobile phone numbers and other details, and saves the updated CSV file. It also writes the Birthday read from the local CSV back to the CALDAV server.
- Fetch contacts from Nextcloud address books.
- Normalize German strings to handle special characters.
- Format phone numbers in a standardized format.
- Writes local CSV file with contact details from Nextcloud.
- Handle birthdays and other contact notes.
- Python 3.x
- Nextcloud instance with CardDAV enabled
- Required Python packages (listed in requirements.txt)
-
Clone the repository:
git clone https://github.com/poggenpower/nextcloud-address-book-integration-poc.git cd nextcloud-address-book-integration-poc
-
Install the required Python packages:
pip install -r requirements.txt
-
Configure the script by creating a config.toml file based on the provided config-example.toml:
this is optional, you can specify each parameter on the CLI too, or use a mixture of both.
csv_file = "address-data-clean.csv" # Replace with your CSV file path output_file = "output.csv" # Replace with desired output CSV file path changes_file = "changes.csv" # Replace with desired changes CSV file path nextcloud_url = "https://your.nextcloud.instance.com" username = "your_nextcloud_username" password = "your_nextcloud_password" group_name = "Test" # Optional address_book_names = ["Contacts", "Other Contacts"]
-
Run the script:
python merge.py --csv_file address-data-clean.csv --vcf_file 2025-01-31_14-10_Abi95.vcf --output_file output.csv --changes_file changes.csv --nextcloud_url https://your.nextcloud.instance.com --username your_nextcloud_username --password your_nextcloud_password --address_book_names Personal Business
--config
allow to specify the path to a config file. use--help
to get some details about the parameters. -
The script will:
- Discover address books in your Nextcloud instance.
- Fetch contacts from the specified address books.
- Update the local CSV file with contact details from Nextcloud.
- Save the updated CSV file to the specified output path.
- send updates for changed vcards (birthday) to the CARDDAV server.
- This project is a proof of concept and may require further enhancements for production use.
- Ensure that your Nextcloud instance has CardDAV enabled and that you have the necessary permissions to access the address books.
- CSV Columnames are hard codes.
This project is licensed under the MIT License. See the LICENSE file for details.
- Nextcloud for providing the CardDAV service.
- vobject for handling vCard parsing.
- phonenumbers for phone number formatting.
For any questions or suggestions, please open an issue.