4

How do I export an attribute table to dbf or txt format by use of Python in ArcGIS 10?

Chad Cooper
12.8k4 gold badges48 silver badges87 bronze badges
asked May 16, 2011 at 5:22
4
  • 2
    Why would you export .dbf to .dbf? Is there any other requirment? Commented 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. Commented May 16, 2011 at 13:24
  • 1
    I 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. Commented May 16, 2011 at 14:48
  • Very similar question about exporting to XLS that you could probably customize to help with your own implementation. Commented Aug 30, 2012 at 19:39

3 Answers 3

18
Import arcpy
arcpy.TableToTable_conversion("MyLayer",r"C:\Output","Mytable.dbf")

I suggest reviewing ArcGIS Online help.

answered May 16, 2011 at 9:31
5

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.

answered May 16, 2011 at 18:02
2
  • Exactly what I did! +1 Commented May 16, 2011 at 18:23
  • This is a good solution because the TableToTable_conversion tool doesn't support exporting to CSV. Commented Jun 23, 2014 at 0:33
4

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.

answered Aug 30, 2012 at 18:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.