Created
August 31, 2022 11:56
-
-
Save youssefeldakar/2d99150eb9a5338cc1efebf4599b3021 to your computer and use it in GitHub Desktop.
Generate vCard contacts from CSV using a template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mobile | name | |
---|---|---|
+##########01 | name1 | |
+##########02 | name2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN:VCARD | |
VERSION:2.1 | |
N:;;;; | |
FN:{{ name }} | |
TEL;CELL;PREF:{{ mobile }} | |
END:VCARD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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