In order for a script tool I'm writing in ArcMap to read fields in a source CSV correctly as text, I need to automate the writing of a shema.ini file in the source directory. In order to do that I need to write a list of fields from an input table to a text file with sequential column names, i.e., "Col1", "Col2", etc. before each field name from the list. Is there a way to insert a sequential number function into a for loop expression that will increment each field name in the list?
addressTable = arcpy.GetParameterAsText(0)
inputDir = os.path.dirname(addressTable)
schemaFile = str(inputDir) + "\schema.ini"
fieldList = arcpy.ListFields(addressTable)
with open(schemaFile, 'w') as f:
for field in fieldList:
f.write("Col" + ???? + "=" + field.name + " Text Width 128\n")
This is an example of what I need to get to:
Col1=UID Text Width 128
Col2=Address Text Width 128
Col3=City Text Width 128
Col4=State Text Width 128
Col5=ZIP Text Width 128