Skip to main content

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.

Release files for vcard-from-csv-morris 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcard-from-csv-morris 0.0.3
File Size Uploaded
vcard_from_csv_morris-0.0.3.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vcard-from-csv-morris 0.0.3
File Interpreter ABI Platform
vcard_from_csv_morris-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / vcard_from_csv_morris-0.0.3.tar.gz

Download URL vcard_from_csv_morris-0.0.3.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
da0d40f82d6dac2e9fc98400e989fe235685a9257866a78e29c5c1dea03766b3
BLAKE2b-256 checksum
How to use checksums
20208fd5baf3ec5f09636b76c5a23971b3d417002eae5cc101839d5fff5ecd14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / vcard_from_csv_morris-0.0.3-py3-none-any.whl

Download URL vcard_from_csv_morris-0.0.3-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
847bb03cb3e765852d0a005d965bf479fe75ce3c6cdaea679f32f917f6db579a
BLAKE2b-256 checksum
How to use checksums
e1d0e1ab7902a3d1f2f3e81ea3179a2f92d0e8062a776a02ab08862d3e780220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page