5

I have many dbf's created by the Spatial Analyst Sample tool. I would like to convert those dbf's into csv's or space delimited (or any text for that matter). I can't seem to find the ArcPy equivalent of "Right click table > Data > Export"

There are a few ideas I saw, which include the use of cursors: Exporting table to XYZ ASCII file via ArcPy? and Bulk convert DBF to CSV in a folder ArcGIS 10.1 using Python

Is there anything simpler and quicker? My tables have over 3 million rows each. I did see the mention of "arcpy.ExportXYv_stats", but that fails with input table is not recognized format etc.

Alternatively, where can I find their dbf specifications? Fortran should be faster.

8

You should be able to use either the Copy Rows tool or the Table to Table tool to get the job done. Just make sure to give your out_table/out_name parameter ends with '.csv' and you should have no trouble.

EDIT: Due to another inexplicable Esri oversight, these tools do in fact force you to save as DBF if you're saving outside of a geodatabase. I maintain that you should be able to use those tools to achieve this, but at this point (ArcGIS 10.2.2) you can't. If it were me, I guess I would end up using an arcpy.da.SearchCursor (as in this answer), which are much faster than the old arcpy.SearchCursor.

  • Great thanks for that suggestion. However no matter what extension I use, that tool outputs a dbf. Here's what I use: infil="2010_LC_xyz.dbf" arcpy.TableToTable_conversion(infil, outpath, "test.csv") . I am now going to try and use sourceforge.net/projects/dbfpy so I just manipulate the dbf directly in Python. – tanksnr Oct 28 '14 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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