2

I have large excel tables with geochemical information that I am importing to ArcGIS. TableToTable works, but there are likely restrictions to the number of columns that can be imported directly from excel as the last columns of my sheet are not included in the table when I open it in ArcGIS. Converting the excel table to csv and importing fixes this, but....

My question is related to the resulting field names and aliases. The headers in my excel/csv table contain special characters that are converted to underscore on import, but I would like to keep these headers as aliases for each field. It is possible to set the resulting aliases manually using the Field Map in the TableToTable conversion tool, but since I have hundreds of columns, I would like to automate this process in a python script.

Can I add the Field Map function to my script such that the headers in the csv table are maintained as Aliases in the new table?

import arcpy
inTable = "Data.csv"
outDB = "Data.gdb"
outTable = "Data"
arcpy.TableToTable_conversion(inTable, outDB, outTable)
2

You would be shooting yourself in the foot if you tried to pass over the special characters that are in Excel into the CSV file. Headers in a CSV must be simple without spaces or special characters. The concept of an alias does not exist in a CSV file format.

So now you are learning a tough lesson, don't use Excel!

It promotes poorly structured data that will never work with ArcGIS. There is a good ESRI blog page about how to format if you use Excel but I would avoid Excel altogether.

Get your data into a personal geodatabase as that promotes good data structure (nice simple headers) but can also accommodate aliases so you can see those special characters like Celsius symbols etc.

  • 1
    +1. One could also convert to table as is and then use pro.arcgis.com/en/pro-app/tool-reference/data-management/… to update the alias of the fields (iterate the sequence of csv headers). – Alex Tereshenkov Aug 22 '16 at 21:02
  • Sounds interesting, and I am trying to get away from using Excel. I'm novice to scripting, so how would I iterate through the headers in the csv file: arcpy.env.workspace = r'Data.gdb' fc = 'Data' csv = r'Data.csv' fieldList = arcpy.ListFields(csv) for field in fieldList: arcpy.AlterField_management(fc, field, field.name, field.alias)' – trulsvik Aug 23 '16 at 8:07
  • There is a similar post here, but I get an error saying too many values to unpack.. gis.stackexchange.com/a/159821/66921 – trulsvik Aug 23 '16 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.