|
POST
|
I double checked the specified fields and everything seems to be good to go... The plan is to join a mdb and a versioned fc then update the fc with the attributes of the mdb.
... View more
03-25-2016
06:20 AM
|
0
|
0
|
1774
|
|
POST
|
I kept getting an error saying I couldn't edit the layer outside an edit session even if I was in an edit session in Arcmap. So, I added the edit operation to the code and it stopped tripping the error.
... View more
03-25-2016
06:17 AM
|
0
|
0
|
1774
|
|
POST
|
I placed a few print statements and everything seemed to be running. So, I added a counter and the script is in fact running but it's only cycling through a record every second or so. We have over 10,000 rows that will have 12 different attributes changed, at this rate it will take entirely too long. When I run the script on a fdb or shp is runs in 2 seconds with the same number of records. I'm new to scripting so I'm not sure if there's something I'm doing wrong. Any suggestions?
... View more
03-25-2016
06:13 AM
|
0
|
3
|
1774
|
|
POST
|
When I run the following script it just spins and spins then arcmap turns to "not responding". I'm trying to update a versioned parcel layer using a .mdb file. When I "quote" out the updatecursor everything seems to run fine and it seems to enter the edit session as well. Any ideas on what it could be? I'm stuck. from time import strftime
print "Start script: " + strftime("%Y-%m-%d %H:%M:%S")
import arcpy
from arcpy import env
sourceFC = r'M:\ParcelDatabase\...\Feb_2016_Ownership'
sourceFieldsList = ["PARCEL","SITUS", "CURRENT_OWNER", "CO_OWNER", "OWNER_MAILADDR", "OWNER_CITY_STATE", "OWNER_ZIPCODE", "TAX_DISTRICT", "TAX_CODE", "SEC", "TOWNSHIP", "RANGE", "LEGAL"]
# Use list comprehension to build a dictionary from a da SearchCursor
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}
arcpy.env.workspace = r"Database Connections\parcelpubdelete.sde"
updateFC = r"Database Connections\...\ArcGISSDE.SDE.TaxParcel"
updateFieldsList = ['PARCELID','SITEADDRESS','OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'ZIPCODE', 'TAX_DIST', 'TAX_CODE', 'SEC', 'TWN', 'RGE', 'PRPRTYDSCRP']
edit = arcpy.da.Editor(r"Database Connections\parcelpubdelete.sde")
edit.startEditing(False, True)
edit.startOperation()
print "entered edit session"
with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:
for updateRow in updateRows:
# store the Join value of the row being updated in a keyValue variable
keyValue = updateRow[0]
# verify that the keyValue is in the Dictionary
if keyValue in valueDict:
# transfer the values stored under the keyValue from the dictionary to the updated fields.
for n in range (1,len(sourceFieldsList)):
updateRow = valueDict[keyValue][n-1]
updateRows.updateRow(updateRow)
del valueDict
edit.stopOperation()
edit.stopEditing(True)
print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S")
... View more
03-24-2016
12:49 PM
|
0
|
12
|
4312
|
|
POST
|
Well, I knew it had to be something easy. I removed the "break" after the if and else statement and it seems to run on all the fields now. I still have a little work to do on the script but I appreciate the help and fast responses.
... View more
03-22-2016
08:52 AM
|
0
|
0
|
1482
|
|
POST
|
After changing the path names to raw path strings, I am still getting the same issue. The script will run but it seems to only go through the first field when I know there are more inconsistencies in other fields. I think the issue might be in the loop.
... View more
03-22-2016
08:00 AM
|
0
|
0
|
1482
|
|
POST
|
I'm new to python so forgive me if this seems like an easy question... I want to compare fields of an mdb and a FC to identify inconsistencies. Also, the field names do not match. So, I have a script using a searchcursor and lists. Right now the script runs but it only seems to run on the first field and I need it to loop through 12 total. Any ideas on how to keep the loop running through all the fields? from time import strftime
print "Start script: " + strftime("%Y-%m-%d %H:%M:%S")
import arcpy
sourceFC = "M:\...\January2015Ownership"
sourceFieldsList = ["PARCEL_","SITUS", "CURRENT_OWNER", "CO_OWNER", "OWNER_MAILADDR", "OWNER_CITY_STATE", "OWNER_ZIPCODE", "TAX_DISTRICT", "TAX_CODE", "SEC", "TOWNSHIP", "RANGE", "LEGAL"]
# Use list comprehension to build a dictionary from a da SearchCursor
valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}
updateFC = "M:\...\TaxParcel_COPY"
updateFieldsList = ['PARCELID','SITEADDRESS','OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'ZIPCODE', 'TAX_DIST', 'TAX_CODE', 'SEC', 'TWN', 'RGE', 'PRPRTYDSCRP']
with arcpy.da.SearchCursor(updateFC, updateFieldsList) as originalRows:
for originalRow in originalRows:
# store the Join value of the row being original in a keyValue variable
keyValue = originalRow[0]
# verify that the keyValue is in the Dictionary
if keyValue in valueDict:
for n in range (1,len(sourceFieldsList)):
if originalRow != valueDict[keyValue][n-1]:
print(str(keyValue) + ' was Changed in field "' + sourceFieldsList + '"')
break
else:
print(str(keyValue) + ' check')
break
del valueDict
print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S")
... View more
03-22-2016
07:42 AM
|
0
|
4
|
4536
|
|
POST
|
I was having difficulty getting the dictionaries working correctly but I stumbled onto a great blog post which was the exact thing I was looking for (link below). Thanks for everyone's help, I've learned a lot from you during this. I look forward to using python for more automation purposes in the future. Turbo Charging Data Manipulation with Python Cursors and Dictionaries import arcpy
...
... sourceFC = "...January2015Ownership.mdb\January2015Ownership"
...
... sourceFieldsList = ["PARCEL_","SITUS", "CURRENT_OWNER", "CO_OWNER", "OWNER_MAILADDR", "OWNER_CITY_STATE", "OWNER_ZIPCODE", "TAX_DISTRICT", "TAX_CODE", "SEC", "TOWNSHIP", "RANGE", "LEGAL"]
...
... # Use list comprehension to build a dictionary from a da SearchCursor
... valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)}
...
... updateFC = "...\ParcelPythonCOPIES.gdb\TaxParcel_COPY"
...
... updateFieldsList = ['PARCELID','SITEADDRESS','OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'ZIPCODE', 'TAX_DIST', 'TAX_CODE', 'SEC', 'TWN', 'RGE', 'PRPRTYDSCRP']
...
... with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows:
... for updateRow in updateRows:
... # store the Join value of the row being updated in a keyValue variable
... keyValue = updateRow[0]
... # verify that the keyValue is in the Dictionary
... if keyValue in valueDict:
... # transfer the values stored under the keyValue from the dictionary to the updated fields.
... for n in range (1,len(sourceFieldsList)):
... updateRow = valueDict[keyValue][n-1]
... updateRows.updateRow(updateRow)
...
... del valueDict
... View more
03-15-2016
03:01 PM
|
1
|
0
|
1480
|
|
POST
|
This worked great and was very fast. However, I'm a bit confused how I can get this to cycle through multiple fields? Maybe use a getparameter to manually set the field after each cycle?
... View more
03-14-2016
02:17 PM
|
0
|
2
|
1480
|
|
POST
|
Thanks for the idea... Ultimately, there will be 12 different fields that will need to be updated. The intention of this script was to run a test on just a few fields (current_ow & situs) for 'proof of concept'.
... View more
03-14-2016
06:29 AM
|
0
|
0
|
1480
|
|
POST
|
yea, 'situs' and 'current_ow' are actual field names.
... View more
03-11-2016
02:25 PM
|
0
|
1
|
2122
|
|
POST
|
I wasn't sure on how to do that, so thanks for the info. Here's the code. import arcpy
countyTB =...January2015Ownership.mdb\January2015Ownership'
fc = ...ParcelPythonCOPIES.gdb\Parcel_092015COPY"
with arcpy.da.SearchCursor(countyTB, ["*"]) as rows:
for row in rows:
fields = rows.fields
idfield = fields.index('PARCEL_')
with arcpy.da.UpdateCursor(fc,['situs', 'current_ow'], "%s = %s" % ('parcel_id', row[idfield])) as urows:
for urow in urows:
urow[1] = row[1]
urows.UpdateRow(urow)
del urow
del row
... View more
03-11-2016
02:24 PM
|
0
|
0
|
1480
|
|
POST
|
I thought about model builder but this will run for more than 10,000 features so I was worried about it being too slow. Although, I'm not too familiar with MB so I may be wrong.
... View more
03-11-2016
02:14 PM
|
0
|
4
|
2122
|
|
POST
|
Oops I forgot I corrected that one... When that is taken out I get the following error... Runtime error Traceback (most recent call last): File "<string>", line 9, in <module> RuntimeError: An invalid SQL statement was used. [Parcel_092015COPY]
... View more
03-11-2016
09:16 AM
|
0
|
1
|
2122
|
|
POST
|
I'm new to python so forgive me if this seems like a dumb question... I work for the city and we get parcel information monthly from the county. Usually the data comes in a text file which I then put in an mdb. I'm trying to write some code to run an update our layers with the updated monthly information. Currently, I've just been trying to get a few fields to update inside a 'test' file geodatabase but I'm stuck. I get the following error message with the following code. Any ideas?
... View more
03-11-2016
09:01 AM
|
0
|
17
|
7389
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a week ago | |
| 1 | 06-19-2018 08:41 AM | |
| 1 | 03-22-2019 01:19 PM | |
| 1 | 09-08-2020 06:22 AM | |
| 1 | 12-10-2015 09:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|