How do I export an attribute table to dbf or txt format by use of Python in ArcGIS 10?
-
2Why would you export .dbf to .dbf? Is there any other requirment?Tomek– Tomek2011年05月16日 09:04:37 +00:00Commented May 16, 2011 at 9:04
-
3@Tomek Your response was converted to a comment to preclude downvotes due to it not being a proper reply.whuber– whuber2011年05月16日 13:24:24 +00:00Commented May 16, 2011 at 13:24
-
1I was recently asked to create a script to convert from feature table to csv simply because dbf is a nightmare and a half. I would recommend going text, personally, and converting elsewhere if necessary.Nathanus– Nathanus2011年05月16日 14:48:42 +00:00Commented May 16, 2011 at 14:48
-
Very similar question about exporting to XLS that you could probably customize to help with your own implementation.RyanKDalton– RyanKDalton2012年08月30日 19:39:01 +00:00Commented Aug 30, 2012 at 19:39
3 Answers 3
Import arcpy
arcpy.TableToTable_conversion("MyLayer",r"C:\Output","Mytable.dbf")
I suggest reviewing ArcGIS Online help.
I'm not familiar with ArcPy yet, but I have done many conversions like this using arcgisscripting.
With arcgisscripting, you could use a SearchCursor to read the table and Python has a great csv module for reading and writing to csv files.
All you need to do is load each row of the SearchCursor into a python list object and the csv writer object will write the list to the output file using the writer.writerow(list) method.
Or, using ArcPy and the arcpy.ExportXYv_stats tool, just specify exporting to a csv. The super-easy way to do it is to use ModelBuilder to build a tool with the 'Spatial Statistics' -> 'Utilities' -> 'Export Feature Attribute to ASCII' utility, specify exactly how you want it to be exported (.csv, tab delimited, whatever), and then export the model builder script to python. Then you can run that script in a loop for all your files.