Skip to content

Instantly share code, notes, and snippets.

@helen-fornazier
Created August 24, 2018 19:24
Show Gist options
  • Save helen-fornazier/2feae50d17d518697b0406892304119b to your computer and use it in GitHub Desktop.
Save helen-fornazier/2feae50d17d518697b0406892304119b to your computer and use it in GitHub Desktop.
#!/bin/python
# pip install openpyxl
from openpyxl import load_workbook
wb = load_workbook(filename='report-2018-08-24T1437.xlsx', read_only=True)
#print (wb.get_sheet_names())
ws = wb['Attendees']
# Nome completo
# Tipo documento (RG, CPF, PASSAPORTE)
# Documento
# E-mail
# Empresa
# Motivo
# Periodo de validade da senha em dias, aceito os seguintes valores: 1,
#3, 7, 15, 30, 90, 180
#Exemplo de uma linha do arquivo:
#Maria;rg;1234567890;email@email.com.br;Unicamp;Evento Unicamp;7
def cstr(cell):
v = cell.value.replace(";", "-")
return v.replace(",", "-")
for row in ws.rows:
if row[2].value and \
row[3].value and \
row[14].value and \
row[27].value:
nline = cstr(row[2]) + " " + cstr(row[3]) + \
";cpf" + \
";" + cstr(row[14]) + \
";" + cstr(row[4]) + \
";" + cstr(row[27]) + \
";Evento Unicamp (linuxdevbr)" + \
";3"
print(nline.encode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment