Select to view content in your preferred language

"ERROR 160385: Workspace or data source is read only." when running ExportTable. Tried all solutions I've found so far...

255
5
4 weeks ago
Labels (3)
MegRFay
Emerging Contributor

Hi there,

I have run the code below on multiple occasions with no problems, but lately have been running into an error. I use arcpy.conversion.ExportTableto bring csvs housed on a network drive to tables in my working gdb (Code Below). I have tried the following solutions I found on Esri Community and GISStackExchange.

I have also restarted my computer. When I check the output in the GUI, it seems some of the rows/observations in the csv are exported to the gdb before the error is returned. Any suggestions are more than welcome, but please check the error handling and previous attempts. Thank you!

# Step 4. Create tables from csv files

# set workspace to gdb
arcpy.env.workspace = gdb

for in_table in in_tables_ed:
    print(f"Processing {in_table}...")
    
    # Check if the input file exists
    if not os.path.exists(in_table):
        print(f"Error: {in_table} does not exist")
        continue
    
    # Resolve output name
    out_name = os.path.basename(in_table).replace('.csv', '')
    
    # Check if the table already exists in the geodatabase
    if arcpy.Exists(out_name):
        print(f"Table {out_name} already exists in the geodatabase. Skipping...")
        continue
    
    try:
        # Export the table
        arcpy.conversion.ExportTable(in_table, out_name)
        print(f"Converted {in_table} to table {out_name} in {gdb}")
    except arcpy.ExecuteError:
        print(f"Failed to export {in_table}. Error: {arcpy.GetMessages(2)}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

 

Tags (4)
0 Kudos
5 Replies
MegRFay
Emerging Contributor

Sometimes the error is " Error: ERROR 000224: Cannot insert features - The table was not found." Again, after some amount of rows have been exported. I am completely confused.

0 Kudos
MichaelVolz
Esteemed Contributor

Can you try running the script where the csv file is local to the machine to see if in that scenario you get successful repeatable results?

If that works I would add code to copy csv file to local drive from shared drive before running the geoprocess.

I say this because I have experienced these kind of issues when trying to source data from a network location as well as save data to a network location.

0 Kudos
MegRFay
Emerging Contributor

Worth a shot! I'll mark as solution if this works, although some of my data are quite large and transferring to and fro often takes longer than its worth

0 Kudos
DanPatterson
MVP Esteemed Contributor

although deprecated, but still available, can you sub in

Table To Table (Conversion)—ArcGIS Pro | Documentation

because the error message suggests it is rare and there is a feedback link to provide info to support

160385: Workspace or data source is read only.—ArcGIS Pro | Documentation

worth a shot, since there is no public-facing report on the bug list


... sort of retired...
0 Kudos
MegRFay
Emerging Contributor

Thank you for your reply! I started with TabletoTable and had the same issues. I will submit feedback to support if I can't find a solution by EOD. 

0 Kudos