|
POST
|
How do you start reading the CSV File from the second line...I have a header...
... View more
10-04-2016
12:32 PM
|
0
|
8
|
2640
|
|
POST
|
Yes as I parse the CSV I set the Hour and Minute to Variables... Hour Minute 16 2 This results in 4:02:00 PM when I run it in ArcGIS with the formula above.
... View more
10-04-2016
12:04 PM
|
0
|
0
|
5483
|
|
POST
|
I am trying to calculate a date/time field in Python with not much luck... In ArcGIS I am doing this with a calculate and it calculates fine...its going into a Date Field. (Right("00" & [Hour],2) + ":" + Right("00" & [Minute],2)) result: 4:02:00 PM I want to do this in Python and am trying this after reading in a CSV File. No error but no result in the feature class created. If I dont get the syntax correct it tells me "Right" is not defined Hour = str(lineSplit[3]) Minute = str(lineSplit[4]) CalcDate1 = "Right('00' & Hour,2) & ':' & Right('00' & Minute,2)" print CalcDate1 It gives me this in the results window in the shell: Right('00' & Hour,2) & ':' & Right('00' & Minute,2)
... View more
10-04-2016
11:52 AM
|
0
|
15
|
10883
|
|
POST
|
OK I think I am making great progress with you help Brittney....THANKS A TON....This is what I have.... IF I go into the csv file and remove the header field names I get it to import fine. If I keep the header there I am getting errors because of field types etc...I cant seem to get it to start on the SECOND line of the CSV file.... import arcpy fc = r'C:\Users\tjv36463\Desktop\Bear Collar\BearLocationImports.gdb\BearCollar' #Insert cursor for the Bikes feature class #cursor = arcpy.da.InsertCursor ("bikes",["X", "Y","Address","SHAPE@XY"]) cursor = arcpy.da.InsertCursor (fc,["CollarSeri", "Year", "Julianday", "Hour", "Minute", "Activity", "Temperatur", "Latitude", "Longitude", "HDOP", "NumSats", "FixTime", "Date", "_2D_3D", "SHAPE@XY"]) #Read through each line of the csv, but skip the first row because it is the header #The count variable skips of the first row count = 0 for ln in open (r"C:\Users\tjv36463\Desktop\Bear Collar\rangedate_D032491_20160822124644.csv", 'r').readlines(): #if count > 0: lineSplit = ln.split(",") print lineSplit #Each line in the csv is a string, so turn it into a list so you can reference each column #lineSplit = ln.split(",") #print lineSplit #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 = str(lineSplit[3]) Minute = str(lineSplit[4]) Activity = str(lineSplit[5]) Temperature = str(lineSplit[6]) Latitude = float(lineSplit[7]) Longitude = float(lineSplit[8]) HDOP = str(lineSplit[9]) NumSats = str(lineSplit[10]) FixTime = str(lineSplit[11]) _2D_3D = str(lineSplit[12]) Date = str(lineSplit[13]) # working with Date Time http://stackoverflow.com/questions/1521906/how-to-specify-date-and-time-in-python shapeVal = (Longitude, Latitude) #Insert the values from csv into feature class #The order of the fields here, matches the order of the fields in line 4 cursor.insertRow ([CollarSeri, Year, Julianday, Hour, Minute, Activity, Temperature, Latitude, Longitude, HDOP, NumSats, FixTime, Date, _2D_3D, shapeVal]) count += 1 del cursor print ("done")
... View more
10-04-2016
09:26 AM
|
0
|
11
|
2640
|
|
POST
|
I modified your code a bit to this...I am getting an error.... I am a bit confused with the SHAPE@XY I am using that when I index the variables and when I add it to the Feature Class....but there is no field for shapeXY.... Any thoughts? THANKS again for you help. >>> ================================ RESTART ================================ >>> <da.InsertCursor object at 0x0000000007000C30> Traceback (most recent call last): File "C:/Users/tjv36463/Desktop/Bear Collar/ImportBearData.py", line 28, in <module> CollarSerialNumber = int(lineSplit[0]) NameError: name 'lineSplit' is not defined import arcpy fc = r'C:\Users\tjv36463\Desktop\Bear Collar\BearLocationImports.gdb\BearCollar' #Insert cursor for the Bikes feature class #cursor = arcpy.da.InsertCursor ("bikes",["X", "Y","Address","SHAPE@XY"]) cursor = arcpy.da.InsertCursor (fc,["CollarSerialNumber", "Year", "Julianday", "Hour", "Minute", "Activity", "Temperature", "Latitude", "Longitude", "HDOP", "NumSats", "FixTime", "2D/3D", "Date", "SHAPE@XY"]) #Read through each line of the csv, but skip the first row because it is the header #The count variable skips of the first row count =0 for ln in open (r"C:\Users\tjv36463\Desktop\Bear Collar\rangedate_D032491_20160822124644.csv", 'r').readlines(): if count > 0: #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) # xVal = float(lineSplit[0] # yVal = float(lineSplit[1] # addVal = lineSplit[2] # shapeVal = (xVal, yVal) CollarSerialNumber = int(lineSplit[0]) Year = int(lineSplit[1]) Julianday = int(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 = int(lineSplit[9]) NumSats = int(lineSplit[10]) FixTime = int(lineSplit[11]) _2D_3D = int(lineSplit[12]) Date = str(lineSplit[13]) shapeVal = (Longitude,Latitude) #Insert the values from csv into feature class #The order of the fields here, matches the order of the fields in line 4 #cursor.insertRow([xVal, yVal, addVal, shapeVal]) cursor.insertRow ([CollarSerialNumber, Year, Julianday, Hour, Minute, Activity, Temperature, Latitude, Longitude, HDOP, NumSats, FixTime, _2D_3D, Date, shapeVal]) count += 1 del cursor
... View more
10-04-2016
07:26 AM
|
0
|
1
|
2640
|
|
POST
|
Brittney...thanks for you reply So in you table/csv file example you have 3 fields correct? Xval, Yval and an address Correct? "bikes" is you variable to the csv file location correct? cursor = arcpy.da.InsertCursor ("bikes",["X", "Y","Address","SHAPE@XY"]) xVal = float(lineSplit[0])
yVal = float(lineSplit[1])
addVal = lineSplit[2]
shapeVal = (xVal, yVal)
... View more
10-04-2016
06:32 AM
|
0
|
1
|
2640
|
|
POST
|
Do I need to import into a table and then create an event layer then append to Feature class?
... View more
10-03-2016
01:33 PM
|
0
|
0
|
3485
|
|
POST
|
I have a CSV file I dont think I can use SHAPE@XY. DO I use the two XY FIelds somehow in the script?
... View more
10-03-2016
01:23 PM
|
0
|
18
|
4245
|
|
POST
|
How does it know what fields my XY Coordinates are in? Add fields like this? #search ....snip (csv, ['SHAPEXY'], [date], [field1], [field2]) as cursor: ...snip # Insert ....snip (fc, ['SHAPEXY'], [date], [field1], [field2]) as cursor: ...snip
... View more
10-03-2016
11:58 AM
|
0
|
21
|
4245
|
|
POST
|
I have a loaded processing question and looking for some ideas...below is what I need to do... I am importing a CSV file which ultimately will be a feature class. So if we start with the END result (Feature class) and I am looking to import a CSV file the question arises.....Can I append a CSV File to a Feature Class....I say no because there is no geometry in the CSV file other than Lat Long...SO that would bring us full circle (Assuming that the Master Feature Class already exists) to the beginning where I would have create a Staging feature class from the CSV and then append into the Master Feature Class housing all the records. Proposed Steps: Delete Staging Feature Class (Used to import the CSV file) Import CSV file to stand alone table Create Event Layer via Lat Long Fields in CSV File Export to Feature Class (This is the Staging layer mentioned above) Do some field processing to new Feature Class Append to Master Feature Class Any other thoughts...did that make sense?
... View more
10-03-2016
05:39 AM
|
0
|
28
|
11688
|
|
POST
|
I have a loaded processing question and looking for some ideas...below is what I need to do... I am importing a CSV file which ultimately will be a feature class. So if we start with the END result (Feature class) and I am looking to import a CSV file the question arises.....Can I append a CSV File to a Feature Class....I say no because there is no geometry in the CSV file other than Lat Long...SO that would bring us full circle (Assuming that the Master Feature Class already exists) to the beginning where I would have create a Staging feature class from the CSV and then append into the Master Feature Class housing all the records. Proposed Steps: Delete Staging Feature Class Import CSV file to stand alone table Create Event Layer via Lat Long Fields in CSV File Export to Feature Class Do some field processing to new Feature Class Append to Master Feature Class Any other thoughts...did that make sense?
... View more
09-30-2016
12:17 PM
|
0
|
1
|
1411
|
|
POST
|
1. I have a feature class created through ArcGIS Survey 123 which is housed in our Org. ArcGIS Online. 2. I have a feature class Map Service on my server, not in ArcGIS Online. 3. I want to Join the Survey 123 Feature class with the Map Service FC and put these in an ArcGIS online Web App. Can this be done? If so any suggestions would be appreciated.
... View more
09-30-2016
11:40 AM
|
0
|
2
|
1880
|
|
POST
|
1. I have a feature class created through ArcGIS Survey 123 which is housed in our Org. ArcGIS Online. 2. I have a feature class Map Service on my server, not in ArcGIS Online. 3. I want to Join the Survey 123 Feature class with the Map Service FC and put these in an ArcGIS online Web App. Can this be done? If so any suggestions would be appreciated.
... View more
09-30-2016
11:39 AM
|
0
|
0
|
899
|
|
POST
|
I am very new to python and look for some examples to import a txt file into SDE....appending to existing data. Any ideas?
... View more
09-22-2016
07:56 AM
|
0
|
1
|
1728
|
|
POST
|
Can I hide a series of fields (description, actions needed, actions taken) and then show them if a Yes/No field is set to Yes? Sign Condition Yes / No If yes then show these fields Description Actions Needed Actions Taken I know you can do this in Survey 123 but not really liking that app.
... View more
09-14-2016
07:35 AM
|
0
|
1
|
1384
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-20-2018 11:09 AM | |
| 1 | 09-10-2018 06:26 AM | |
| 1 | 09-15-2022 11:02 AM | |
| 1 | 05-21-2021 07:35 AM | |
| 1 | 08-09-2022 12:39 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-19-2022
09:23 PM
|