1

I am currently creating a script that will read data in one (to many) Excel spreadsheet(s) and would like to know how to get a count of the number of spreadsheets entered by the user. The script will only read the data in the GISData$ sheet of each spreadsheet file. So far I have the below code but need something to replace 'rowCount' as this doesn't seem to be working. I would like to just get a count of the number of spreadsheets selected.

spreadsheets = arcpy.GetParameter(1)

for idx in range(0, spreadsheets.rowCount):
    input_spreadsheet = str(spreadsheets.getValue(idx,0))
        input_spreadsheet += r"\GISData$

...do something...

Thanks in advance.

2
  • This question will help you working with Excel files & sheets: gis.stackexchange.com/questions/65035/… Then if you have a multivalue parameter, you can treat it as a list and return its length (if there's only 1 GISData] sheet per xls file)
    – GISGe
    Commented May 21, 2014 at 12:15
  • What datatype is the parameter? Commented May 21, 2014 at 12:16

1 Answer 1

2

I think that arcpy.GetParameter(1).values is a list. So you can try len(arcpy.GetParameter(1).values) to get a count of the number of values selected.

2
  • This returns 'list' object has no attribute 'values'
    – Howeitzer
    Commented May 21, 2014 at 15:17
  • if arcpy.GetParameter(1) is already a list the count is the size of this list : len(arcpy.GetParameter(1)) Commented May 21, 2014 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.