POST
|
I get KeyError: 5 error when running my script tool. Background of the script: Earlier in the script, i do a summary statistics and I am editing the fields to get the field alias so the output looks cleaner because later in the script, table to excel is run to export the table. Here is what my script looks like: fieldList = arcpy.ListFields(in_table)
length = len(fieldList)
arcpy.DeleteField_management(in_table, nodeIDField)
alias_dict = {1: 'Network ID', 2: 'Project ID', 3: 'Municipality', 4: 'Node Count'}
for i, field in enumerate(fieldList):
if field.type != 'OID':
newfield = '{}new'.format(field.name)
arcpy.AddField_management(in_table, newfield, field.type, field.precision,
field.scale, field.length, alias_dict[i], field.isNullable, field.required, field.domain)
arcpy.CalculateField_management(in_table, newfield, '!{}!'.format(field.name), "PYTHON_9.3")
arcpy.DeleteField_management(in_table, field.name)
When running this, the existing fields do get modified with the alias I want for each, but then get KeyError: 5 error. My thought is that it is because the key 5 does not exist. How do I get the script to just pass through to the next portion of the script if the key of 5 does not exist?
... View more
03-13-2018
10:50 AM
|
0
|
3
|
3061
|
POST
|
James, so I figured out what I was doing wrong. So originally in my script I have a template GDB where that is copied to create another workplace GDB. After that, I attempt to append the data. Originally my tempalte GDB was corrupt and had no data in it and thus I went the step of creating feature classes within the copied GDB, thus this thread being created. However, now that my GDB is not corrupt, I don't have to create new features in the GDB. Thanks for the help!
... View more
02-22-2018
06:58 AM
|
0
|
0
|
1944
|
POST
|
Hi James, I saw this as a possible solution when I was researching this error before. Question though, do I have to add the validate function within my script for every feature class being created?
... View more
02-21-2018
01:13 PM
|
0
|
2
|
1944
|
POST
|
Hi Joe, so the error said it takes place where I am trying to create the feature class arcpy.CreateFeatureclass_management(outLocation, fiberFC, fiber_geometry, fiberTemplate) where outLocation is a geodatabase that is created earlier in my script (this part works). It's the create feature class that is giving me issues. Of course my GDB does not have any spaces.
... View more
02-21-2018
01:05 PM
|
0
|
1
|
1944
|
POST
|
Hello, In order to do a network analysis without altering the existing data, I am creating a new GDB that will then have the 3 feature classes I need created within and then the data appended to it. However, when I try to create the feature class in my script, I get an error saying invalid characters. I looked up the error but couldn't derive a solution. Any help is greatly appreciated. Here is my script: outLocation = copied_Geodatabase
fiberFC = 'Fiber'
fiberTemplate = arcpy.mapping.ListLayers(mxd, 'Fiber Segments')[0]
fiber_geometry = 'POLYLINE'
arcpy.CreateFeatureclass_management(outLocation, fiberFC, fiber_geometry, fiberTemplate)
... View more
02-21-2018
12:37 PM
|
0
|
7
|
2862
|
POST
|
So there are roughly 600 values in the NetworkID field, which is proprietary information to my company, and the color code I provided was the primary color my company uses and is associated with us. I am trying to change the text of the NetworkIDs to be the color of that color code ( #FAAF41). Right now, there is no vision as to where we are going with the attribute expressions capability of AGOL but my company wants me to get familiar with it and test it out on existing data we have to see what I can do with it and if I can get it working while the higher ups decide what they want customized. Hopefully that explanation helps a bit.
... View more
09-19-2017
01:18 PM
|
1
|
2
|
560
|
POST
|
Yea removing line 10 took out the error for unexpected identifier, however with this code now for Attribute Expressions, i get the execution error: runtime error: cannot call member property on object of this type. I'm fairly new to Arcade and such and do not understand these errors. Any assistance on this bit then? // #FAAF41 Primary Color
var primaryColor = "#FAAF41";
var networkID = $feature.NetworkID;
var color = primaryColor[networkID];
Console(color);
return color
... View more
09-19-2017
09:33 AM
|
0
|
4
|
2041
|
POST
|
// #FAAF41 Primary Color
var primaryColor = "#FAAF41";
var networkID = $feature.NetworkID;
var color = primaryColor[networkID];
Console(color);
return color
<font color="{expression/expr0}"><b>{networkID}</b></font> Xander, In line 10, I get an Unexpected identifier error. Do you know why that is?
... View more
09-19-2017
09:06 AM
|
0
|
6
|
2041
|
POST
|
Thank you Xander! This is my first time working with Arcade and Attribute Expressions in AGOL!
... View more
09-19-2017
05:42 AM
|
0
|
0
|
2041
|
POST
|
Thank you Greg! This is my first time working with Arcade and Attribute Expressions in AGOL!
... View more
09-19-2017
05:41 AM
|
0
|
0
|
2041
|
POST
|
Do you know of any examples where people have tried to change the color of the expressions?
... View more
09-18-2017
12:53 PM
|
0
|
11
|
2041
|
POST
|
I'm currently looking at/researching how to edit attribute expressions and even change the color of text in the expressions. My problem is, I do not know how to go about it or which language to use that would be best. Any links to articles/discussion/resources or even solutions are welcome!
... View more
09-18-2017
12:43 PM
|
0
|
13
|
6985
|
POST
|
But I'd want to check to see if the list that is set to fieldValues is in Field3. So wouldn't it be the other way around from how you have the join listed?
... View more
08-04-2017
01:04 PM
|
0
|
3
|
3308
|
POST
|
Clinton, What if fieldValue had more than one input? Say: fieldValue = '%45B%', '%46A%', '%47C%' Would that still work the way you have the script written?
... View more
08-04-2017
11:58 AM
|
0
|
5
|
3308
|
Title | Kudos | Posted |
---|---|---|
1 | 07-26-2018 09:12 AM | |
1 | 07-18-2017 01:12 PM | |
1 | 03-09-2017 09:57 AM | |
2 | 03-22-2018 09:49 AM | |
1 | 09-19-2017 01:18 PM |