My name is Sphe from South Africa and I am relatively new to programming. I am trying to create workforce assignments using Arcgis Api for python but I am failing. I have tried using these scripts from workforce-scripts/2 - Importing Assignments.ipynb at master · Esri/workforce-scripts (github.com) but I'm still not winning. I get a Key error when i try to import my assignments from a csv.
if tolerance is not None: KeyError: 'Location'
This is the part of the code that is giving me a major headache:
csv_file = pd.read_csv('C:/Users/sphelele.ntilane/Desktop/Book.csv')
csv_file
csv_file_assignments = []
for index, row in csv_file.iterrows():
geometry = geocode(f"{row['Location']} {row['Suburb']}", out_sr=3857)[0]["location"]
csv_file_assignments.append(
workforce.Assignment(
project,
geometry=geometry,
location=row["Location"],
description=row["Description"],
priority=row["Priority"],
work_order_id=row["Work Order ID"],
assignment_type="No_Water",
status="unassigned"
)
)
project.assignments.batch_add(assignments)
Whoever can assist please do
@SpheleleNtilane7 can you provide a sample of the CSV your script is querying?
It looks like your CSV is formatted to use a semi-colon (;) as the delimeter. Pandas defaults to using a comma (,). When reading the CSV, specify the delimeter parameter. Ex:
csv_file = pd.read_csv('C:/Users/sphelele.ntilane/Desktop/Book.csv', delimiter=';')