Hello,
I tried to read a txt file(attached) with 25 length number-like text-type field(‘num2’field in the txt file, e.g. 3123412452000123) in a code below.
ws = path to default.gdb..
csvpath = path to 'sample_q.txt' ..
gj_db.to_csv(csvpath, index=False, encoding='utf-8')
# define the 'num2' field as a text-type field.
fm = Create_Fieldmap(target_feature = csvpath)
build_db = arcpy.conversion.TableToTable(csvpath, ws, "t2t_table")
But, when I use "arcpy.conversion.TableToTable" with fieldmap(to define the field as a text-type field) the line causes error that 'ERROR 001156: Failed on input OID 1, could not write value '2.91101010010084E+24' to output field ..'.
It’s because TableToTable read ‘num2’ value as a floating number(scientific notation).
How can I read the value as text type value?
Thanks in advance for any help!
Jae,
Solved! Go to Solution.
Hey Jae
I think if you create a schema.ini file in the same folder as your txt (csv) file that should work. I just tested it and it's working for me. Good luck!
[tab2tab2.csv]
Format=CSVDelimited
ColNameHeader=True
Col2=num1 Text Width 30
Col3=num2 Text Width 30
Hey Jae
I think if you create a schema.ini file in the same folder as your txt (csv) file that should work. I just tested it and it's working for me. Good luck!
[tab2tab2.csv]
Format=CSVDelimited
ColNameHeader=True
Col2=num1 Text Width 30
Col3=num2 Text Width 30
It solved the issue, though need to make 'schema.ini' file. (thought there might be an environment setting to not write it as a float in scientific notation)
Thank you Dominic,