Skip to main content

Generates vCards based on a provided DataFrame and dictionary of column mappings. The script includes various functions to preprocess the data, validate the column mappings, clean and format the contact information, add a prefix to first names, and create and write the vCard entries to a file.

Project description

VCard Generator

This is a Python script that generates vCards based on a provided DataFrame and dictionary of column mappings. The script includes various functions to preprocess the data, validate the column mappings, clean and format the contact information, add a prefix to first names, and create and write the vCard entries to a file.

Requirements

  • Python 3.0 or higher
  • Pandas library

Usage

  1. Import the required libraries:

    ! pip install vcard-from-csv-morris
    
    import pandas as pd
    from vcard_bulk_create.main import vcf_card_generate
    
    df = pd.read_csv("yourfile.csv")
    
    d = {"first_name": "Name", "phone": "Phone"}
    vcf_card_generate(
       df, d
    )
    
  2. Specify the column mappings as a dictionary. Each key in the dictionary should correspond to one of the valid keys, and the value should be the column name in the DataFrame that corresponds to that key. Ignore the key value pair if not available:

    column_mappings = {
        "last_name": "Last Name Column",
        "first_name": "First Name Column",
        "org": "Organization Column",
        "title": "Title Column",
        "phone": "Phone Column",
        "email": "Email Column",
        "website": "Website Column",
        "street": "Street Column",
        "city": "City Column",
        "p_code": "Postal Code Column",
        "country": "Country Column"
    }
    

    Note: Make sure that the column names in the dictionary match the column names in your DataFrame.

  3. Call the vcf_card_generate function, passing in the DataFrame, column mappings, and any optional parameters:

    vcf_card_generate(df, column_mappings, prefix=None, path=None)
    
    • prefix: A prefix to be added to the first names in the vCards. This is an optional parameter and can be set to None.
    • path: The path to save the vCard file. This is an optional parameter and can be set to None.
  4. The vCard entries will be generated based on the provided DataFrame and column mappings. If a prefix is specified, it will be added to the first names. The vCard entries will be written to a file specified by the path parameter. If no path is provided, the default file name is "result.vcf".

    Example output:

    Generated vcard. 10 of them. At result.vcf
    

Notes

  • The provided DataFrame should include columns corresponding to the valid keys defined in the VALID_KEYS set. If any of the required columns are missing, the script will raise an error.

  • The script performs preprocessing and cleaning operations on the contact information to ensure the vCard entries are formatted correctly. It removes special characters, spaces, and punctuation, and formats names and phone numbers appropriately.

  • The vCard file is written in the vCard 3.0 format, following the mappings defined by the vCard RDF Specification.

  • The script uses the Pandas library for data manipulation. Make sure the library is installed before running the script.

  • The script prints a success message when the vCard generation is complete. The message includes the total number of vCard entries generated and the file path where the vCard file is saved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcard_from_csv_morris-0.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

vcard_from_csv_morris-0.0.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file vcard_from_csv_morris-0.0.2.tar.gz.

File metadata

  • Download URL: vcard_from_csv_morris-0.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for vcard_from_csv_morris-0.0.2.tar.gz
Algorithm Hash digest
SHA256 36c7ec83be82c27e1c4048b2a3074b40721baaa073c8fe040d5975c4689213d1
MD5 2444ccc9960522226e6a21d65beacb2a
BLAKE2b-256 fecb28a3bfca40b46cb3b795d0f98de5f9d617e26c45fefd6e8b841b70d26058

See more details on using hashes here.

File details

Details for the file vcard_from_csv_morris-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for vcard_from_csv_morris-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f46167a14f9ee657583498e5c70298b9f20e9f33ff47cab8f69186a250ee31d1
MD5 94c8a468ea43b877d5fb21fdde02e15d
BLAKE2b-256 9043e206568732c08d77d89137309117a2104fd4c5119f3c6973a562157e2461

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page