Select to view content in your preferred language

Reading excel sheets with arcpy script tool

175
1
09-04-2024 12:00 PM
CCampagna
New Contributor

I am trying to create a script with arcpy that reads several excel sheets within an .xlsx file, then returns the values of the specified cells in the sheets into an attribute table. When I run the tool, the error code returned states that No such file or directory exists to my specified file. A snippet of my code is as follows:

[...]
try:
    file = arcpy.GetParameterAsText(0
    outputFC = arcpy.GetParameterAsText(1)

# ==========================================================================
    # read how many sheets are in file
    df = pd.read_excel(file)

    # read number of columns and rows
    columns = pd.read_excel(file, usecols='A,B,C,D,E,F,G,H')
    while df['value'].sum > 0:
        for rows in columns.iterrows:
            GenInfo = df.iloc[13]
            ConAssess = df.iloc[19]
            Comments = df.iloc[24:33]
[...]
0 Kudos
1 Reply
CodyPatterson
Frequent Contributor

Hey @CCampagna 

You may attempt to do an arcpy.AddMessage(file) just to make sure that it's catching the right link. Something may be causing an issue in the actual file system linkage.

Cody

0 Kudos