POST
|
Hi Chris Fox and Curtis Price , I have a similar issue, but when I use Table to Table (Conversion) my custom Schema.ini file is overwritten by the tool. So if I try to force a field to be a specific type the tool deletes my changes and makes it's own file reverting back to the incorrect field types. I would prefer to hard code each field in the Schema.ini file as long as ArcGIS doesn't overwrite it. Is there a way to lock the file down? Thanks, John S. System: Windows 7 ArcGIS 10.1 Example Schema.ini: [AOIs.csv] Col1=Facility_Name Text Width 20 Col2=Date Date Col3=Leader Text Width 50 Col4=Occurrence Text Width 35 Col5=Nature_of_AOI Text Width 35 Col6=Mapsite Text Width 150 Col7=Distance Text Width 25 Col8=Start_Point Text Width 20 Col9=End_Point Text Width 20 Col10=Total_Length Text Width 20 Col11=Starts_in Text Width 5 Col12=Comment Text Width 255 Example input CSV/Text: Facility_Name,Date,Leader,Occurrence,Nature_of_AOI,Mapsite,Distance,Start_Point,End_Point,Total_Length,Starts_in,Comment Place #1,2/1/2015 00:00,"Appleseed, Johnny",Daily,AOI A,"Site-1",376 Upstream,"012345, 0123456",,,No,At the Termination Point. Place #2,2/2/2015 00:00,"Wayne, Bruce",Daily,AOI B,"Site-2",376 Upstream,"012345, 0123456","012345, 0123456",,No,At the Termination Point. Place #3,2/3/2015 00:00,"Kent, Clark",Daily,AOI C,"Site-3",376 Upstream,"012345, 0123456",,,No,At the Termination Point.
... View more
03-26-2015
06:14 AM
|
0
|
0
|
827
|
POST
|
Wow, you guys are awesome. I've been combing through all of this and still running into a few issues, but this has been exciting. Blake, I tried to incorporate your code, but the values are all dropping through to None. I'm going to look at the last few examples/ideas and see if I can get them hashed out. I'd like to force the CSV to make the "total_length" column a string from the start, but unfortunately the CSVtoTable code I'm using runs a check on the data and makes the columns what the data are. So if it's all integers then it makes it a "LONG" but if it's got a string in it then it defaults to TEXT. We use it to convert other tables so I thought I'd incorporate it here. (It's actually to solve a separate issue with this entire conversion, but in this case it was one step forward to take two back). Thanks everyone for your help so far and when I have it figured out I'll post the result and mark the correct answer. Have a great weekend!
... View more
03-20-2015
09:16 AM
|
0
|
0
|
406
|
POST
|
Hello, I'm not sure if this is the right place to send this so please correct me if I am wrong. I had a script that converted data from a clients site to a usable GIS format until they changed the output. I've tried two different directions with no luck. Due to how an earlier part of the script works, CSV to Table, and the nature of the data being converted; the 'total_length' field that's imported might end up being a string or an integer (TableToTable conversion will not work). I need it to look at the field type and if it's already an integer then populate the 'length_val' field with the number. If it's a string then strip it down to the number (typically the greater than, less than or tilde off the front) and populate the 'length_val' field. In other words: If 'total_length' = STRING, then send only the number to 'length_val' Otherwise, if 'total_length' = INTEGER, then calculate the field. I've been using update cursors to do a lot of the rest of the work, but that doesn't have to be the case. Any assistance would be great. Thanks, John Row[3] = 'total_length' Row[17] = 'length_val' ---First Attempt--- with arcpy.da.UpdateCursor(aoi_table_gdb,aoi_fields) as cursor: totlen = "total_length" #<--- This was just an idea fields = arcpy.ListFields(aoi_table_gdb) for field in fields: if field.name = '"'+ totlen +'"' and field.type = String: for row in cursor: if row[3] == None: row[17] = None elif row[3].find(str('~ ')) > -1: row[17] = row[3].lstrip(str('~ ')) elif row[3].find(str('> ')) > -1: row[17] = row[3].lstrip(str('> ')) elif row[3].find(str('< ')) > -1: row[17] = row[3].lstrip(str('< ')) else: row[17] = row[3] else: for row in cursor: row[17] = row[3] cursor.updateRow(row) ---Second Attempt--- with arcpy.da.UpdateCursor(aoi_table_gdb,aoi_fields) as cursor: for row in cursor: #Length Value if row[3] == None: row[17] = None arcpy.AddWarning("A. Row: " + str(row[1]) + " - " + str(row[3])) elif row[3].isdigit(): row[17] = row[3] arcpy.AddWarning("B. Row: " + str(row[1]) + " - " + str(row[3])) else: length = filter(unicode.isdigit, row[3]) row[17] = length arcpy.AddWarning("C. Row: " + str(row[1]) + " - " + str(row[3]))
... View more
03-13-2015
11:00 AM
|
0
|
12
|
8909
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|