Select to view content in your preferred language

Smartsheet to AGOL

725
2
02-12-2024 10:05 AM
Labels (3)
drWood
by
Regular Contributor

I am trying to follow the steps provided in this blog: https://community.esri.com/t5/arcgis-api-for-python-blog/updating-arcgis-online-hosted-feature-layer... and cannot find a solution to encountered errors when running from the Python window in ArcGIS Pro 3.2.1

 

import smartsheet
import pandas as pd
from arcgis.gis import GIS

access_token = 'xxxxx'
smartsheet = smartsheet.Smartsheet(access_token)
sheetID = '1234567890'

def smartsheet_to_dataframe(sheet):
col_names = [col.title for col in sheet.columns]
row = []
for row in sheet.rows:
cells = []
for cell in row.cells:
cells.append(cell.value)
rows.append(cells)
data_frame = pd.DataFrame(rows, columns=col_names)
return data_frame

sheet = smartsheet.Sheets.get_sheet(sheetID)
df = smartsheet_to_dataframe(sheet)

output_csv = r"C:\TEMP\temp.csv"
df.to_csv(output_csv)

 

 

My attempts to run this script keep prompting the error: 

Traceback (most recent call last):
File "<string>", line 22, in <module>
File "<string>", line 11, in smartsheet_to_dataframe
AttributeError: 'Error' object has no attribute 'columns'

 

Some digging made mention that the arcpy version the environment is directed to may not be compatible with the functions being used, but I have not been able to make any headway regarding that.

 

Thanks in advance for any help!

0 Kudos
2 Replies
Raul
by
Regular Contributor

Haven't really ever used the smartsheet library myself, but frrom the sample code you posted (you should fix the indentation btw) I'd try renaming the variable on line 6 to something else, so it doesn't have the same name as the library you're trying to use.

0 Kudos
CraigCheeseman
Regular Contributor

Did you clone your default environment and make sure that is where you installed your version of the sdk?

0 Kudos