Skip to content

Instantly share code, notes, and snippets.

@tilacog
Created September 13, 2016 18:03
Show Gist options
  • Save tilacog/b1969f073c864ecb9d24da0a0f6ba4db to your computer and use it in GitHub Desktop.
Save tilacog/b1969f073c864ecb9d24da0a0f6ba4db to your computer and use it in GitHub Desktop.
import rows
from collections import Counter
base_svg = '/path/to/drawing.svg'
base_name = 'Fulano de Tal e Coisa'
participants_table = rows.import_from_csv('/path/to/pyse-participantes.csv')
with open(base_svg) as f:
svg = f.read()
counter = Counter()
for row in participants_table:
new_svg = svg.replace(base_name, row.nome)
# uniquefy filename
counter.update([row.email])
filename = '{count}-{email}.svg'.format(
count=counter[row.email],
email=(row.cc if row.cc else row.email)
)
with open(filename, 'w') as output:
output.write(new_svg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment