Automatically generate a csv file with the data obtained in a survey123 survey////Generar de manera automática un csv con los datos obtenidos en una e

597
1
01-10-2022 04:22 AM
JavierCMartínezPrieto
Occasional Contributor

Good morning/afternoon/evening:
I have a survey in survey123 and would like to generate a csv, with the following fields:
- Date
- Month
- Project.
- Driver.
- Km done.
These fields are inside the survey
This csv must be generated automatically.
You have to make a notebook that generates it and that is executed monthly (on the 1st day of the following month).

With this script I manage to create a csv, with the data that I enter manually:
import csv
with open ('PVehiculo2.csv', 'w') as csvfile:
fieldnames=['Date', 'Month', 'Project', 'Driver', 'Km_realized']
writer = csv.DictWriter (csvfile, fieldnames=fieldnames)

writer.writeheader()
writer.writerow({'Date': '06/01/2022',
'Month':'March',
'Project': '151641163',
'Driver': 'jGarcia',
'Km_realized': '140'
})
writer.writerow({'Date': '10/01/2022',
'Month':'March',
'Project': 'Almo',
'Driver': 'jGarcia',
'Km_realized': '135.6'
})
writer.writerow({'Date': '11/01/2022',
'Month':'March',
'Project': '0206510',
'Driver': 'jGarcia',
'Km_realized': '150.6'
})
print ("data inserted")

But I would like it to be done with the data that is in the survey and that the file is generated once a month.

thanks in advance to all of you who participate.

Regards

##############################En español###########################################

Buenos dias/tardes/noches:
poseo una encuesta en survey123 y me gustaria generar un csv, con los siguientes campos:
• Fecha
• Mes
• Proyecto.
• Conductor.
• Km realizados.
Estos campos se encuentran dentro de la encuesta
Este csv se tiene que generar de manera automática.
Hay que hacer un notebook que lo genere y que se ejecute de manera mensual (los días 1 del mes siguiente).

con este script consigo crear un csv, con los datos que yo introduzco manualmente:
import csv
with open ('PVehiculo2.csv', 'w') as csvfile:
fieldnames=['Fecha', 'Mes', 'Proyecto', 'Conductor', 'Km_realizados']
writer = csv.DictWriter (csvfile, fieldnames=fieldnames)

writer.writeheader()
writer.writerow({'Fecha': '06/01/2022',
'Mes':'Marzo',
'Proyecto': '151641163',
'Conductor': 'jGarcia',
'Km_realizados': '140'
})
writer.writerow({'Fecha': '10/01/2022',
'Mes':'Marzo',
'Proyecto': 'Almo',
'Conductor': 'jGarcia',
'Km_realizados': '135.6'
})
writer.writerow({'Fecha': '11/01/2022',
'Mes':'Marzo',
'Proyecto': '0206510',
'Conductor': 'jGarcia',
'Km_realizados': '150.6'
})
print ("datos insertados")

Pero me gustaría que se realizara con los datos que hay en la encuesta y que se genere el archivo una vez al mes

gracias de ante mano a todos lo que participéis.

Saludos

Javier C. Martinez Prieto
Tags (3)
0 Kudos
1 Reply
AdminGIS2
New Contributor III

You could query the feature service that Survey123 reports to for the results from last month (using ArcGIS REST API) and replace your dictionary by those results. If it has to be a Notebook you probably need Notebook Server. Otherwise, you could schedule the script on another device or server using Windows Task Scheduler. 

0 Kudos