1

I am attempting to convert 5 fairly large CSV files into DBFs using ArcPy.

My code is below.

Currently when I run this script I am met with the following error:

ExecuteError: ERROR 999999: Error executing function. Failed to execute (TableToTable).

Code below:

# Convert CSVs to DBase tables in preparation for join to FeatureClass

dir_list = os.listdir(some dir)

boro_list = ["Qn", "Mn", "Bk", "Bx", "Si"]

dir_list = [x for x in dir_list if x.endswith("csv") and x[-6:-4] in boro_list]

print(dir_list)

arcpy.env.workspace = "some dir"

for csv in dir_list:
    arcpy.TableToTable_conversion(csv, "some gdb", os.path.splitext(csv)[0] + "_dbf")
    print("Successfully converted" + os.path.splitext(csv)[0] + ".csv to " + os.path.splitext(csv)[0] + ".dbf")

Printing dir_list prior to defining my env workspace yields a list of the 5 desired filenames for the CSVs. When done in ArcMap I am able to convert without problems using the manual version of the TableToTable_conversion tool.

  • 2
    You need to specify the input gdb as a raw string, like you're doing for the workspace. – mikewatt Oct 29 '18 at 17:24
3

Your output path in Table to Table is wrong in a couple places. This should fix it:

 arcpy.TableToTable_conversion(csv, os.path.join(r"D:\DCP\DataEng\MapPluto\MapPLUTOTest.gdb", os.path.splitext(csv)[0] + ".dbf"))
  • you have _dbf instead of .dbf
  • you didn't have a slash between the output fgdb and the output file name. as-is the name would end up like MapPLUTOTest.gdbOutputFCName_dbf
  • 1
    you need to make the string os.path.join(r"D:\DCP\DataEng\MapPluto\MapPLUTOTest.gdb",.. because you're using backslashes, in this case you might get away with it as \D and \M aren't escape characters but if the GDB was called newMapPLUTOTest.gdb there would be problems with \n. – Michael Stimson Oct 30 '18 at 7:04
  • You're right - I missed the use of black slash (). I cheated and added r to the string to make it correct. – KHibma Oct 30 '18 at 12:20

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.