Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
2  
Why would you export .dbf to .dbf? Is there any other requirment? –  Tomek May 16 '11 at 9:04
2  
@Tomek Your response was converted to a comment to preclude downvotes due to it not being a proper reply. –  whuber May 16 '11 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. –  Nathanus May 16 '11 at 14:48
    
thank you so much –  wetland May 16 '11 at 19:40
    
Very similar question about exporting to XLS that you could probably customize to help with your own implementation. –  RyanDalton Aug 30 '12 at 19:39

3 Answers 3

up vote 4 down vote accepted

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.

share|improve this answer
Import arcpy
arcpy.TableToTable_conversion("MyLayer",r"C:\Output","Mytable.dbf")

I suggest reviewing ArcGIS Online help.

share|improve this answer

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.

share|improve this answer
    
Exactly what I did! +1 –  Nathanus May 16 '11 at 18:23
    
This is a good solution because the TableToTable_conversion tool doesn't support exporting to CSV. –  Fezter Jun 23 at 0:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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