Field formatting issue (importing XY Data from CSV - Python)

321
2
03-02-2022 10:51 AM
TamnaSidhart
New Contributor

I'm using ArcPro 2.7.0. I'm working on a python script that brings in X,Y data from a CSV using the arcpy.MakeXYEventLayer_management tool provided by ArcGIS arcpy module. The ultimate goal is to use the data in the CSV to show a time slider in ArcPro. I have a field (T) that has the time formatted as: YYYYMMDDHHMMSS.

I have no issue displaying the X,Y point and creating a shapefile with it. My issue is the field leaves out the seconds at the end of each value in the Time(T) field.

For example, the values would be 202002251200000, 202002251200001, 202002251200002, 202002251200003 etc., but they all come out as 202002251200000 (seemingly rounding the values) despite being correct in my CSV after running my script.

The field type in the Excel CSV is 'General'. Is there something I'm missing in my XY Event layer tool in the script below?

I've tried a few things such as change the field type to type 'Number' with zero decimal places.

My script in Python:

# Run MakeXY Event Layer, creating point locations, assign to arbitrary spatial ref
spRef = arcpy.SpatialReference(32616)
arcpy.MakeXYEventLayer_management("testplot.csv", "Y", "X", "XY_Points.lyr", spRef)

# Process: Feature Class to Feature Class
arcpy.CopyFeatures_management("XY_Points.lyr", "XY_PointData")

# Creating Grid Buffer Index Features
arcpy.GraphicBuffer_analysis("XY_PointData.shp", "GridIndexFeatures.shp", "2.5 meters", "SQUARE", "MITER")

# Delete unnecessary fields from Grid Index shapefile
arcpy.DeleteField_management("GridIndexFeatures.shp", ["BUFF_DIST", "ORIG_FID"])

 

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

try Excel To Table (Conversion)—ArcGIS Pro | Documentation first then the make event layer.  If numbers don't work you might have to try it as a text field


... sort of retired...
0 Kudos
DavidPike
MVP Frequent Contributor

Shapefile format doesn't store date and time in the same field.  Create a Feature Class within a File Geodatabase.

0 Kudos