Skip to content

jharuda/vcf2csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vcf2csv

Introduction

This program converts vCard also know as VCF (Virtual Contact File) to human readable format such as CSV. There are some supported output formats like CSV, JSON, Python dictionary and formated print. This program requires Python programming language installed on your system.

This has only been tested on VCF version 2.1.

Usage

Basic usage (Python dictionary)

This will print output data to stdout. It uses input file as required parameter. All of those examples have also short version of parameters.

python ./vcf2csv.py --input tests/data/contacts_3_version2-1.vcf

# or short version

python ./vcf2csv.py -i tests/data/contacts_3_version2-1.vcf

CSV

python ./vcf2csv.py -i tests/data/contacts_3_version2-1.vcf --output ./out.csv

JSON

python ./vcf2csv.py -i tests/data/contacts_3_version2-1.vcf --json ./out.json

Nice print

python ./vcf2csv.py -i tests/data/contacts_3_version2-1.vcf --nice

Skip field

There are fields such as ID, N, FN, TEL_CELL_PREF and others. You can skip this field.

python ./vcf2csv.py -i tests/data/contacts_3_version2-1.vcf --skip-fields FN

Skip contacts

You can skip contacts based on ID.

python ./vcf2csv.py -i tests/data/contacts_3_version2-1.vcf --skip-contacts 2

Help

usage: vcf2csv [-h] -i INPUT [-o OUTPUT] [-j JSON] [-s [SKIP_FIELDS ...]] [-S [SKIP_CONTACTS ...]] [-n]

The script converts Android contacts VCF file to CSV.

options:
  -h, --help            show this help message and exit
  -i, --input INPUT     Input path to the .vcf file
  -o, --output OUTPUT   Output path where to export .csv file
  -j, --json JSON       Output path where to export JSON file
  -s, --skip-fields [SKIP_FIELDS ...]
                        Skip some VCF 'field' from output
  -S, --skip-contacts [SKIP_CONTACTS ...]
                        Skip VCF 'contact' from output based on ID
  -n, --nice-print      Print data on STDOUT and format it properly

Tests

Tests are placed in the tests folder. The test writes to temp folder. The tests are writen in BASH. To run the test use the following command.

bash tests/run_tests.sh

License

MIT

About

Convert VCF file (mobile contacts) to CSV

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages