2

I am trying to export a table from a mxd using arcpy. I need a comma delimited .txt file. I believe the CopyRows_management function should work, however I always get a cannot create output error number 000210.

# new 6_ export script
import arcpy, os

finalFolder = r"C:\workspace\CRAI_outside_finalDeliv\SectionA"

# intermediate variables:
GISMXD = os.path.join(finalFolder, "4_ArcGIS_Map_Documents\SectionA.mxd")
folder6_hvl = os.path.join(finalFolder, "6_GPS_Horizontal_Vertical_Location")
txtFilePath = os.path.join(folder6_hvl, "SectionA_SiteMarker_WGS84_DD.txt")

GISMapDoc = arcpy.mapping.MapDocument(GISMXD)
DF = arcpy.mapping.ListDataFrames(GISMapDoc)[0]
GsMPLay = arcpy.mapping.ListLayers(DF)[0]
# I consistently get an error 000210 cannot create output on the next line.  Can't figure out why.
arcpy.CopyRows_management(GsMPLay, txtFilePath)

del DF
del GISMapDoc

Ultimately I want to be able to do something like what is done in this question: Copy, not export, a table from Arcmap but using arcpy. The full error message is:

Runtime error  Traceback (most recent call last):   File "<string>", line 15, in <module>   File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 15215, in CopyRows     raise e ExecuteError: ERROR 000210: Cannot create output C:\workspace\CRAI_outside_finalDeliv\SectionA\6_GPS_Horizontal_Vertical_Location\SectionA_SiteMarker_WGS84_DD.txt Failed to execute (CopyRows).  

I'm using Arc 10.3, python 2.7.

Craig T
  • 464
  • 3
  • 13
  • Do you have Microsoft Security Essentials/Windows Defender? – Brandon G. Mar 29 '17 at 14:55
  • Also, post your full error message. – Brandon G. Mar 29 '17 at 15:23
  • What is your source layer that you wish to export? Some data sources do not export well. It may be an issue with the connection or permissions if it is a database table being exported. – Get Spatial Mar 29 '17 at 15:36
  • I do have windows defender, but it hasn't been an issue before, it is pretty well configured. I am exporting a point feature class in a geodatabase with domains; the point class is joined to a table in the same gdb. I've edited the question with the full error message. – Craig T Mar 29 '17 at 15:47

1 Answers1

2

To output a table to a text file, use TableToTable_conversion (http://desktop.arcgis.com/en/arcmap/10.4/tools/conversion-toolbox/table-to-table.htm).

arcpy.TableToTable_conversion(GsMPLay, folder6_hvl, "SectionA_SiteMarker_WGS84_DD.txt")
Dan Jurgella
  • 2,378
  • 13
  • 15
  • I have never gotten table to table to convert to anything other than dbf tables, and a .txt is what I need. – Craig T Mar 29 '17 at 15:53
  • If you specify the name of the output table as ".txt", it will be converted to a text file. – Dan Jurgella Mar 29 '17 at 16:48
  • Even when I specify the output as a .txt, it comes out as a .dbf. Example:

    arcpy.TableToTable_conversion(GsMPLay, r'C:\workspace\CRAI_outside_finalDeliv\RSNC_Section63A\6_GPS_Horizontal_Vertical_Location', "output2.txt")

    <Result 'C:\workspace\CRAI_outside_finalDeliv\RSNC_Section63A\6_GPS_Horizontal_Vertical_Location\output2.dbf'>

    sorry for the bad formatting, I'm having difficutly configuring this.

    – Craig T Mar 29 '17 at 16:52
  • That is strange. You might want to edit the question to highlight the specific issue of not being able to convert to a text file. Have you tried the TableToTable_conversion on other layers/featureclasses with the same result? What happens when you try it with a text file as the input? Does it still convert it to a dbf? Can you export to a .txt successfully from the ArcMap attribute table? – Dan Jurgella Mar 29 '17 at 18:58
  • I can export from an arcmap table to whatever format I want the normal way, I just can't do it with arcpy. I've tried a variety of inputs with that tool, including xls, csv, shp, and feature classes with the same result of a dbf. – Craig T Mar 29 '17 at 19:05