Created
April 22, 2019 15:41
-
-
Save javierwilson/4e7d96ef58ec1b8243c6264311edb78a to your computer and use it in GitHub Desktop.
Convierte commcare export a Excel compatible con sistema LAC
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/python | |
# -*- coding: utf-8 -*- | |
import pandas as pd | |
commcare_data = pd.read_excel("commcare.xlsx", header=0) | |
lac_data = pd.read_excel("lac.xlsx", sheet_name="BENEFICIARIO", header=1) | |
for index, commcare_row in commcare_data.iterrows(): | |
if commcare_row["form.dui"] in lac_data[u"Número de Identificación"]: | |
print commcare_row["form.dui"] | |
lac_row = pd.DataFrame({ | |
u"Nombre de Proyecto":["SOS"], | |
u"Organización Implementadora":["LWR"], | |
u"Número de Identificación":[commcare_row["form.dui"]], | |
u"Nombre completo":[commcare_row["form.nombre"]], | |
u"Sexo":[commcare_row["form.sexo"][0].upper()], | |
u"Fecha de Nacimiento":[commcare_row["form.nacimiento"]], | |
u"Educación":[commcare_row["form.estudios"]], | |
u"Teléfono":[commcare_row["form.telefono"]], | |
u"Hombres en su familia":[commcare_row["form.hombres_hogar"]], | |
u"Hombres en su familia":[commcare_row["form.mujeres_hogar"]], | |
u"Organización Perteneciente":[commcare_row["form.nombre_org"] if commcare_row["form.nombre_org"] <> "---" else ""], | |
u"País":["EL SALVADOR"], | |
u"Departamento":[commcare_row["form.dpto"]], | |
u"Municipio":[commcare_row["form.municipio"]], | |
u"Comunidad":[commcare_row["form.comunidad"]], | |
u"Fecha de ingreso al proyecto":[commcare_row["form.fecha_inscripcion"]], | |
}) | |
lac_data = lac_data.append(lac_row, sort=False) | |
lac_data.to_excel("lac_new.xlsx", index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment