Geographic Information Systems Asked by NSD on January 19, 2021
My code
import arcpy, os, shutil, re
from arcpy import env
arcpy.env.workspace = "R:GIS_DataEarthquake_DataUpdatesEq_updates.mdb"
path = r"R:GIS_DataEarthquake_DataUpdates"
In_path = r"R:GIS_DataEarthquake_DataUpdatesOGS_Auto_Updatescsv"
Out_path = r"R:GIS_DataEarthquake_DataUpdatesOGS_Auto_Updatesdbf_new"
#gdb_name = r"R:GIS_DataEarthquake_DataUpdatesEq_updates.mdb"
connect = "\"
# convert csv to dbf in a separate folder
# Local variables inputs and outputs: filenames
for filenames in os.listdir(In_path):
arcpy.TableToTable_conversion(filenames, r"R:GIS_DataEarthquake_DataUpdatesEq_updates.mdb", os.path.splitext(filenames)[0] + ".dbf")
print("Successfully converted" + os.path.splitext(csv)[0] + ".csv to " + os.path.splitext(csv)[0] + ".dbf")
The error:
File "C:Program Files (x86)ArcGISDesktop10.5ArcPyarcpyconversion.py", line 2249, in TableToTable
raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Rows: Dataset 2000-2009.csv does not exist or is not supported Failed to execute (TableToTable).
Am I missing a import or other command?
There are several issues with the code:
You should add a file extension check after os.listdir to make sure your only looking at .csv files:
for filenames in os.listdir(In_path):
if filenames.endswith('.csv'):
# continue on with code
Next, your saving a .dbf to a .mdb file which is not possible. Change the out path to the Out_path variable.
Finally, since the env workspace is pointing to the mdb the in_table parameters needs the full file path, update the table to table statement to this:
# exporting to folder
arcpy.TableToTable_conversion(os.path.join(In_path, filenames), Out_path, os.path.splitext(filenames)[0] + ".dbf")
Answered by artwork21 on January 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP