Hello,
I have big script (in a python toolbox) that can take in GPS Collar data from several manufacturers and spits out a feature class for review before it is added to the main database. One of the manufacturers outputs their data in a csv. So I'm just doing a table to table conversion and then going through the rest of the script. The issue is that only the date is coming through and leaving the time for some reason. I don't think it would be too onerous to split up the column in the csv before it was imported (I have another CSV but their date and time come separated and I combine them into 1), but it seems like this shouldn't be a problem in the first place as I'm using a field calculator to just input the entire column into the feature class:
arcpy.management.CalculateField(output_path, 'UTC',
expression='!Date___Tim!',
expression_type='PYTHON 3',
code_block="""""",
field_type='DATE'
)
Also tried converting it to a string, but it seems to be losing the time when the CSV is converted to the table, but I have no idea why that would be.
The format in the CSV is:
%m/%d/%Y %H:%M:%S
Thanks!
Solved! Go to Solution.
I see the same issue until I add a column title for the missing column, and remove the invalid column names (spaces, special characters, etc).
If I ensure ALL the fields have a name, and that name is a single word, then it converts to table as expected with date and time in the fields.
If you run the Table to Table GP tool in Pro, it appears as if it "fixes" these issues on the fly. With the python code, however, I had to fix the column name issues before it worked.
R_
Could you share a sample CSV?
I've noticed the same behavior in the Table To Table GP tool in pro if I try .csv or .xls.
However, if I open the csv in Excel and save as .xlsx, then the date/time imports as expected.
R_
I see the same issue until I add a column title for the missing column, and remove the invalid column names (spaces, special characters, etc).
If I ensure ALL the fields have a name, and that name is a single word, then it converts to table as expected with date and time in the fields.
If you run the Table to Table GP tool in Pro, it appears as if it "fixes" these issues on the fly. With the python code, however, I had to fix the column name issues before it worked.
R_
Awesome will give that a shot!