Hi, I have scripted a process to read a CSV file into a file geodatabase. Then, I want to read this imported file and work on it by adding new fields and calculating values. However, while using the arcpy.ListTables() on the geodatabase does not list the table. I am just confused what is wrong. Any help !!Here is my script------------------------- outLocation = dbLoc+'\\'+ out_name +'.gdb' arcpy.env.workspace = where_tables_are # the folder where your tables are # Make list of all tables in workspace tables = arcpy.ListTables("GDB*") print tables try: for tb in tables: # Execute TableToGeodatabase print "Importing "+tb+ " to gdb: " + outLocation arcpy.TableToGeodatabase_conversion(tables, outLocation) env.workspace = os.path.dirname(os.path.dirname(__file__))+'\\'+ out_name +'.gdb' arcpy.RefreshCatalog(env.workspace) inTables = arcpy.ListTables()
outLocation = dbLoc+'\\'+ out_name +'.gdb' arcpy.env.workspace = where_tables_are # the folder where your tables are # Make list of all tables in workspace tables = arcpy.ListTables("GDB*") print tables try: for tb in tables: # Execute TableToGeodatabase print "Importing "+tb+ " to gdb: " + outLocation arcpy.TableToGeodatabase_conversion(tables, outLocation) env.workspace = os.path.dirname(os.path.dirname(__file__))+'\\'+ out_name +'.gdb' arcpy.RefreshCatalog(env.workspace) inTables = arcpy.ListTables()
import arcpy import os inWS = r'H:\Documents' #the directory that contains the .csv files outGDB = r'H:\Documents\ArcGIS\Default.gdb' #the output Geodatabase arcpy.env.workspace = inWS csvlist = arcpy.ListFiles('*.csv') print csvlist for csvfile in csvlist: csvname = os.path.splitext(csvfile)[0] print "converting " + str(csvname) arcpy.TableToTable_conversion(csvfile, outGDB, csvname + '_tab')
arcpy.env.workspace = outGDB tables = arcpy.ListTables("*_tab") for table in tables: print table #do the rest of the work here
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.