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

Source Code

GitHub Repository

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.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

vcard_from_csv_morris-0.0.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vcard_from_csv_morris-0.0.3.tar.gz
  • Upload date:
  • Size: 4.6 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.3.tar.gz
Algorithm Hash digest
SHA256 da0d40f82d6dac2e9fc98400e989fe235685a9257866a78e29c5c1dea03766b3
MD5 b752c77537dc7fe98100dbaa7d1c2488
BLAKE2b-256 20208fd5baf3ec5f09636b76c5a23971b3d417002eae5cc101839d5fff5ecd14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for vcard_from_csv_morris-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 847bb03cb3e765852d0a005d965bf479fe75ce3c6cdaea679f32f917f6db579a
MD5 c67eb2dd8420c4694070be401331f81b
BLAKE2b-256 e1d0e1ab7902a3d1f2f3e81ea3179a2f92d0e8062a776a02ab08862d3e780220

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