I'm using Jupyter Notebook in ArcGIS Pro 2.9.3. I am attempting to create assignments in Workforce using a CSV file.
I have used the code samples provided online related to this topic and cannot get mine to work. I apologize in advance for posting the table and code as images. The formatting was off when attempting to place in the body.
I tried commenting out the line generating the error and another line would be the cause.
| xField | yField | Type | Location | Dispatcher | Description | Priority | WorkOrderId | DueDate | Attachment | Worker |
| -57.8306 | 43.31751 | Quality Inspection | NB | RT | Mc | None | 55553003 | ######## | | PK |
| -59.6505 | 42.64011 | Quality Inspection | NB | RT | G | None | 65521560 | ######## | | PK |
| -59.5653 | 42.6353 | Quality Inspection | NB | RT | G | None | 65521740 | ######## | | PK |
df = pd.read_csv("Workforce_July_Inspects.csv")
vu_assignments = []
for index, row in df.iterrows():
geometry = {"x" : row['xField'], "y" : row['yField'], "spatialReference" : {"wkid" : 4326}},
vu_assignments.append(
workforce.Assignment(
project,
geometry=geometry,
location=row['Location'],
description=row['Description'],
priority=row['Priority'],
work_order_id=row['WorkOrderId'],
#assigned_date=datetime.now(),
due_date=row['DueDate'],
worker=row['Worker'],
dispatcher=row['Dispatcher'],
assignment_type='Quality Inspection'
#assignment_type=row['Type']
#status="assigned"
)
)
project.assignments.batch_add(assignments)
The error I got was:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) In [42]: Line 17: assignment_type='Quality Inspection' File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\assignment.py, in __init__: Line 182: self.due_date = due_date File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\assignment.py, in due_date: Line 467: self._set_datetime_attr(self._schema.due_date, value) File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\feature_model.py, in _set_datetime_attr: Line 111: timestamp = to_arcgis_date(value) if value is not None else None File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\apps\workforce\utils.py, in to_arcgis_date: Line 23: return datetime_obj.timestamp() * 1000 AttributeError: 'str' object has no attribute 'timestamp' ---------------------------------------------------------------------------