Skip to main content
added 2 characters in body
Source Link

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable)


And this is what the schema.ini file created by the script looks like"like:

[Sample_200.csv]
Format=CSVDelimited
ColNameHeader=True
REGISTRATION_NUMBER TEXT Width 128
Address TEXT Width 128
City TEXT Width 128
State TEXT Width 128
ZIP TEXT Width 128

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable)


And this is what the schema.ini file created by the script looks like"
[Sample_200.csv]
Format=CSVDelimited
ColNameHeader=True
REGISTRATION_NUMBER TEXT Width 128
Address TEXT Width 128
City TEXT Width 128
State TEXT Width 128
ZIP TEXT Width 128

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable)


And this is what the schema.ini file created by the script looks like:

[Sample_200.csv]
Format=CSVDelimited
ColNameHeader=True
REGISTRATION_NUMBER TEXT Width 128
Address TEXT Width 128
City TEXT Width 128
State TEXT Width 128
ZIP TEXT Width 128
added 260 characters in body
Source Link

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable) 


And this is what the schema.ini file created by the script looks like"
[Sample_200.csv]
Format=CSVDelimited
ColNameHeader=True
REGISTRATION_NUMBER TEXT Width 128
Address TEXT Width 128
City TEXT Width 128
State TEXT Width 128
ZIP TEXT Width 128

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable)

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable) 


And this is what the schema.ini file created by the script looks like"
[Sample_200.csv]
Format=CSVDelimited
ColNameHeader=True
REGISTRATION_NUMBER TEXT Width 128
Address TEXT Width 128
City TEXT Width 128
State TEXT Width 128
ZIP TEXT Width 128
added 21 characters in body
Source Link

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable)

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable)

I am trying to import a CSV to GDB using an ArcMap script tool and preserve some string fields that look like numbers as strings. I added some code to create and populate a schema.ini file in the CSV's source directory but ArcMap doesn't seem to recognize/honor it. It is created immediately but appears to only be populated a minute or so later once the rest of the tool is finished running. The new schema.ini file appears to be identical to one I manually edited that does work. It seems to possibly be an order of operations issue, any suggestions? Here is my code for this piece of the workflow so far:

addressTable = arcpy.GetParameterAsText(0)
tableName = os.path.basename(addressTable)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
schemaHeader = "[" + str(tableName) + "]\n"

file = open(schemaFile, 'w')
file.write(schemaHeader)
file.write("Format=CSVDelimited\n")
file.write("ColNameHeader=True\n")
fieldList = arcpy.ListFields(addressTable)
for field in fieldList:
    file.write(field.name + " TEXT Width 128\n")
file.close               
arcpy.conversion.TableToTable(addressTable, workingGDB, tempTable)
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
Loading
added 11 characters in body
Source Link
Loading
added 78 characters in body
Source Link
Loading
deleted 23 characters in body
Source Link
Loading
added 5 characters in body
Source Link
Loading
Source Link
Loading