Which parameter data type will work for an excel spreadsheet?

294
5
Jump to solution
03-05-2021 02:06 PM
JeremiahJones
New Contributor II

I am trying to pass in an excel spreadsheet as in input into my script tool using arcpy.GetParametersAsText()

The script does post processing on the spreadsheet, the script itself works when it is run with hard coded file paths. However, I cannot seem to find the correct parameter data type to give to the tool in ArcGIS Pro. This tool takes in 2 files, one is a csv which it has no problem taking. The other is the excel spreadsheet which arc recognizes but only as a file that is holding a table. I cannot get arc to pass the whole file into the tool.

Any suggestions would be useful.

Thanks,

J

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Notable Contributor

Well, in my excel to table, I used Any Value, so give it a shot if you don't want to navigate to a sheet

excel_to_table.png


... sort of retired...

View solution in original post

0 Kudos
5 Replies
DanPatterson
MVP Notable Contributor

Try workspace, then you have to read the sheet name

python - Reading Excel sheet in ArcPy script? - Geographic Information Systems Stack Exchange

Alternately, just get the filename and you can use the xlrd module directly


... sort of retired...
JeremiahJones
New Contributor II

My issue is the data type parameter when making the script tool. I can't find the correct parameter type that will just pass in the excel file. Basically it needs to be passed in as a filepath.

There is no issues with my script, it runs and processes as intended. Arc just won't allow me to give the filepath to the spreadsheet.

Hopefully this screenshot will help. With the MSAG_Current as a file, arc will see the xl spreadsheet but asks me to open it, because it wants the table inside. Which isn't what my script wants, all the script wants is the filepath.

Thank you Dan.

0 Kudos
DanPatterson
MVP Notable Contributor

Well, in my excel to table, I used Any Value, so give it a shot if you don't want to navigate to a sheet

excel_to_table.png


... sort of retired...

View solution in original post

0 Kudos
JeremiahJones
New Contributor II

Well, if I navigate to the xlsx file using Any Value it still wants to open up to the table. But if I use the path to the table I just delete the table from the path and the script runs. That may be the best I get.

ESRI should have a XLSX parameter in my opinion, but hey that's why they pay me the small bucks. 🙂

Thank you Dan.

0 Kudos
MarkBryant
New Contributor III

If you just want to point to an excel file (and not a sheet/range within the file) use the FILE data type, and then set the filter to XLSX.

MarkBryant_0-1615262854035.png

 

Mark.