I have a large list of coded domains.
They are numbers like: 01.6530.01, 05.7991.08, 05.7991.01, 05.7991.06
The code will be the exact same as the description.
I've tried to make a list using:
FRClist = [01.6530.**01**, 05.7991.08, 05.7991.01, 05.7991.06]
but it gave me a syntax error on the 01 that is bolded.
So I tried to change all the values to a string, using:
FRCstr = str(01.6530.**01**, 05.7991.08, 05.7991.01, 05.7991.06)
but it still gave me a syntax error on the same bolded 01.
In the end I hope to put the list into this:
arcpy.AddCodedValueToDomain_management(GDBpath, "FRC", FRClist[x], FRClistp[x] )
I have quite a few domains which require a lot of coded values.
-
3If by chance you already have the values in a table then you may find it easier to use the Table to Domain tool.PolyGeo– PolyGeo ♦2012年11月04日 22:19:18 +00:00Commented Nov 4, 2012 at 22:19
1 Answer 1
In the Add Coded Value To Domain documentation there are code examples that show you how to do this. It looks like you are trying to submit a list of coded values to a function that is designed to take a coded value at a time. I think you should change your code to iterate through your list instead.
Python will not like 01.6530.01 being treated as a number because it is not a number. To treat it as a string I think you will need to use the str function on each value you add to the list rather than trying to turn the list as a whole into a string.
-
2
-
2Also I believe the Table to Domain tool (
TableToDomain_management
function in arcpy) can read a CSV file directly as the input table. You'll want to separate records in a CSV file by new lines though. So if the only column you have is your list of values, put each value on its own line.blah238– blah2382012年11月04日 22:45:05 +00:00Commented Nov 4, 2012 at 22:45 -
You said that you had the list in a txt file so why not use a throwaway Python script to take the values in that file and reformat with quotes or str functions onto a single line of a throwaway file that you can copy/paste into the actual script.2012年11月04日 23:23:10 +00:00Commented Nov 4, 2012 at 23:23
-
1Why the arbitrary restriction of no external files? This is getting pretty off-topic for this site BTW.blah238– blah2382012年11月04日 23:42:51 +00:00Commented Nov 4, 2012 at 23:42