Mitch Holley, Darren Wiens THANK YOU FOR YOUR HELP AND SUPPORT....Things are running great...although not the most efficient way but I got it...with YOUR help of course
ANY QUESTIONS: please feel free to reply and I will get back with you..
THANKS Again Mitch and Darren....SOOOO very much appreciated.
1. Read CSV to file to get all records
2. I calculated the Time field (CalcTime) from an Hour and Minute Field..
12:02:00 AM
3. Once I had that I calculated the Full CalcDateTime field from CalcTime above and the Date field from the CSV
6/29/2016 12:02:00 AM
4. Inserted ROWS into the Feature Class using SHAPE@XY Token to create the geometry
Hour Minute from CSV File
0 2
getTime3 Variable - CalcTime Field Result in New Feature Class
12:02:00 AM
getDateTime Variable - CalcDateTime field result in the New Feature Class concatenated with the Date field from the CSV File
6/29/2016 12:02:00 AM
FULL CODE BELOW
import arcpy
import datetime
def getdate(Hour, Minute):
return datetime.datetime.strptime(str(Hour).zfill(2) + ' ' + str(Minute).zfill(2), '%H %M')
fc = r'C:\Users\\Collar\BearLocationImports.gdb\BearCollar'
cursor = arcpy.da.InsertCursor (fc,["CollarSeri", "Year", "Julianday", "Hour", "Minute", "Activity", "Temperatur", "Latitude", "Longitude", "HDOP", "NumSats", "FixTime", "Date", "_2D_3D", "BearID", "CalcDate", "CalcDate3", "SHAPE@XY"])
for ln in open (r"C:\Users\tjv36463\Desktop\Bear Collar\rangedate_D032495_20160822124736_NH.txt", 'r').readlines():
#Each line in the csv is a string, so turn it into a list so you can reference each column
lineSplit = ln.split(",")
#Use index positions to get the right column from the csv
#Make sure the data is the correct type (i.e. X and Y need to be numbers, not strings)
CollarSeri = long(lineSplit[0])
Year = str(lineSplit[1])
Julianday = str(lineSplit[2])
Hour = int(lineSplit[3])
Minute = int(lineSplit[4])
Activity = int(lineSplit[5])
Temperature = int(lineSplit[6])
Latitude = float(lineSplit[7])
Longitude = float(lineSplit[8])
HDOP = str(lineSplit[9])
NumSats = int(lineSplit[10])
FixTime = int(lineSplit[11])
_2D_3D = int(lineSplit[12])
BearID = 0
Date = str(lineSplit[13]) # working with Date Time http://stackoverflow.com/questions/1521906/how-to-specify-date-and-time-in-python
getTime = getdate(Hour, Minute)
getTime2 = str(getTime)
getTime3 = getTime2[-8:]
getDateTime = (Date + getTime3)
print getDateTime
shapeVal = (Longitude, Latitude)
#Insert the values from csv into feature class
cursor.insertRow ([CollarSeri, Year, Julianday, Hour, Minute, Activity, Temperature, Latitude, Longitude, HDOP, NumSats, FixTime, Date, _2D_3D, BearID, getTime3, getDateTime, shapeVal])
count += 1
del cursor
print ("done")