Hi GeoNet and thanks in advance. I'm new to Python.
My goal is to write a script that converts all the shapefiles in a gdb into a csv (although I will take an Excel spreadsheet, too). I plan to convert the final program into a script tool with parameters for which gdb to access and where to save the spreadsheets. I can get a single shapefile to convert into an Excel spreadsheet. I would like to loop through the gdb and convert each shapefile to a unique csv (for this case, let's assume that the gdb contains only shapefiles).
My code fails and I have received a couple of different error messages depending on the variable I use for the in_table argument (hope I have that right).
I suspect that I am not correctly naming my in_table and out_xls variables.
Here's a screen shot of my code. Sorry for the small size, not sure how to enlarge the text.
What is getOutput?
.getOutput is a method called on a result object. This is the most direct way to get the result value from GetCount (or any other tool that returns a result.) The result is a string, so that's why he wrapped it with int() -- to convert '45' to 45 for a count of 45 rows.
Yes just change the workspace and output folder on your side.
Thanks FC.
Question:
This part of your code (below) looks like a parameter in a script tool. Do I need to create a script tool and designate this as a parameter? If so, I think it should be an output. What data type is it considered. Thanks again.
.getOutput(0))
Curtis Price already answered this for you above...
.getOutput is a method called on a result object. This is the most direct way to get the result value from GetCount (or any other tool that returns a result.) The result is a string, so that's why he wrapped it with int() -- to convert '45' to 45 for a count of 45 rows.
Thanks for the reminder.
Thanks FC!
Your code works for me. I need to take it a few steps further to create a script tool for my specific needs. Much appreciated.
Glad you found a solution! Don't forget to Mark a reply as the Correct Answer.
Excel files are limited to 65535 rows:
This is true for .xls format, but not .xlsx.
Understanding how to use Microsoft Excel files in ArcGIS—Help | ArcGIS Desktop
THANKS ALL. I will review each of the replies in detail and try each suggestion.
Doug