Skip to content

Instantly share code, notes, and snippets.

@youssefeldakar
Created August 31, 2022 11:56
Show Gist options
  • Save youssefeldakar/2d99150eb9a5338cc1efebf4599b3021 to your computer and use it in GitHub Desktop.
Save youssefeldakar/2d99150eb9a5338cc1efebf4599b3021 to your computer and use it in GitHub Desktop.
Generate vCard contacts from CSV using a template
mobile name
+##########01 name1
+##########02 name2
BEGIN:VCARD
VERSION:2.1
N:;;;;
FN:{{ name }}
TEL;CELL;PREF:{{ mobile }}
END:VCARD
#!/usr/bin/env python
import sys
import pandas
from jinja2 import Template
data = pandas.read_csv(sys.stdin)
with open('vCard.j2') as f:
tmpl = Template(f.read())
for i, row in data.iterrows():
print(tmpl.render(row))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment