|
POST
|
I tried this again but i am not getting an error. The Export_Output layer is a shapefile and the fields that are in the layer that i don't need are Shape*, OBJECTID, Shape_Leng & Shape_Area Traceback (most recent call last): File "c:\program files (x86)\arcgis\desktop10.6\ArcToolbox\Scripts\TableToExcel.py", line 224, in <module> arcpy.GetParameter(3)) File "c:\program files (x86)\arcgis\desktop10.6\ArcToolbox\Scripts\TableToExcel.py", line 194, in table_to_excel for row in cursor: RuntimeError: Cannot find field '' Failed to execute (TableToExcel). import arcpy
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "Export_Output")[0]
#Exports NotifiedLots tabel to excel table
intable = lyr
# Create a fieldinfo object
fieldInfo = arcpy.FieldInfo()
# Get the fields from the input
fields= arcpy.ListFields(intable)
for field in fields:
if field.type != 'OID' and field.type != 'Shape':
fieldInfo.addField(field.name, field.name, "VISIBLE", "")
if field.type == 'OID':
fieldInfo.addField(field.name, field.name, "HIDDEN", "")
# Create table view
arcpy.MakeTableView_management(intable, "Notif_view", "", "", fieldInfo)
# Export to Excel
arcpy.conversion.TableToExcel("Notif_view", r"C:\TEMP\Notif_view.xls")
... View more
11-15-2019
09:51 AM
|
0
|
4
|
3500
|
|
POST
|
I am still have the the FID, Shape_Lenth & Shape_Area fields after the export to Excel after using what you posted
... View more
11-01-2019
02:24 PM
|
0
|
6
|
3500
|
|
POST
|
Ya I agree i could just open the excel spreadsheet and delete them if i were only doing it so often. I usually run this process about 10 times a week. So i was trying to make it as stream lined as possible.
... View more
11-01-2019
02:14 PM
|
1
|
0
|
1303
|
|
POST
|
Jake, Thanks for the recommendation but I would have thought that just dropping or removing the fields would be easier. I didn't want to do the field mapping.
... View more
11-01-2019
11:21 AM
|
0
|
10
|
3500
|
|
POST
|
I need to export attributes from a certain layer in Arcmap but without the OID & Geometry fields to excel. I've tried the following bet i am getting error ("AttributeError: DescribeData: Method areaFieldName does not exist") on line 15. I would appreciate any help with the code, thanks. import arcpy
import os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Notified")[0]
arcpy.env.workspace = os.path.dirname(mxd.filePath)
wp = os.path.dirname(mxd.filePath)
fc = "Notified"
desc = arcpy.Describe(fc)
f = desc.fields
fields = [f.name for f in f if f.name != desc.OIDFieldName and f.type != 'Geometry' and f.name != desc.areaFieldName and f.name != desc.lengthFieldName]
for fld in fields:
fields.remove(fields)
arcpy.MakeQueryTable_management(fc, "tmp_table", "NO_KEY_FIELD")
arcpy.TableToExcel_conversion("tmp_table", Notified_xls)
... View more
11-01-2019
09:57 AM
|
0
|
14
|
5021
|
|
POST
|
I wasn't playing the comma correctly in "TAX " + ", TAX ". I had it "TAX " +, " TAX ", thanks. Although it put "TAX" in every row even one's that didn't have any tax numbers i just another udpatecursor to remove all the extra values with just "TAX".
... View more
10-04-2019
11:07 AM
|
0
|
0
|
1273
|
|
POST
|
OK, i wasn't sure what you meant by that. One more question if you don't mind. How can i add 'TAX' to the out puts based on your code? With the following i get '30-A-1-D', '30-A-1-D-A', '30-A-1-F' with arcpy.da.UpdateCursor(recs,['Legal','Legal2']) as cursor:
for row in cursor:
row[1] = ','.join(extract_tax_ids(pattern.split(row[0].upper()))).strip()
cursor.updateRow(row) I want to get TAX 30-A-1-D, TAX-A-1-D-A, TAX-30-A-1-F, etc.
... View more
10-03-2019
11:57 AM
|
0
|
2
|
1273
|
|
POST
|
Joshua i think you are right there might be some case that i'll have to manually address. question if you don't mind, based on your code you mentioned that i wouldn't be able to pass a list of values directly into a single field with the update cursor do you mind sharing how i can do this please?
... View more
10-02-2019
08:31 AM
|
0
|
4
|
1273
|
|
POST
|
The code worked but i think the data in the legal field has lots of variations and i thought that the tax number ended before an alpha number but it doesn't, some will be TAX 30-A-1-E or TX 30-A-1, etc. 27-4N-3W SW BEALS ACREAGE E 278' OF TX 30-A OF BLKS 3,4,5,6 LESS TX 30-A-1 LS ST
22-4N-3W NE DEMENT TAX 7-B BLK 52 IN DEMENT & BOONE CALD
27-4N-3W SW BEALS ACREAGE TAX 14-B IN BLK 4 LESS TAX 14-B-1
27-4N-3W SW BEALS ACREAGE TAX 20, TAX 30-A-1-E BLK 3
27-4N-3W SW BEALS ACREAGE TX 30-A-1-D-A BLK 6
24-4N-5W NE TAX 2&3 IN NENE
31-4N-2W SW LONGVIEW PLACE TX 1 IN BLKS 1,2,3,LS HWY,, TX 4,5 IN BLK 3 & TX 9,10 IN BLK 4 TX 8 IN BLK 6
24-3N-2W NW NESW LESS TAX 34 & 46, S 1/2 NW LS TX 67 IN SWNW,,TX 46-A IN NESW
21-4N-3W NE CALLOWAY ADD TX 4 & 5 & W 7' OF S 114' OF TX 3 IN LT 3 LS HWY BLK 2
1. should be TX 30-A, TX 30-A-1 2. should be TAX 7-B 3. Should be TAX14-B, TAX 14-B-1 4. Should be TAX 20, TAX 30-A-1-E 5. Should be TX 30-A-1-D-A 6. Should be TAX 2, TAX3 or TAX 2&3 7. TX1, TX 4&5, TX9&10 8. TAX 34 &46. TX 46-A or TAX34, TAX46, TX 46-A 9. Should be TX 4&5, TX 3 or TX 4, TX 5, TX 3 Running a print i get the following. 20', '30-A-1-E']
['43']
['33', '4', '17', '30-A-1-B']
['4', '33', '30-A-1-A']
['18', '30A1CC']
['30-A-1-F']
['30-A-1-D', '30-A-1-D-A', '30-A-1-F']
['30-A-1-C-A']
['30-A-1-C-B']
['7', '7A', '7B', '7C']
... View more
10-01-2019
02:22 PM
|
0
|
6
|
4326
|
|
POST
|
Some times it' not before the IN, some times it's before other alpha characters. It does appear to before alpha characters though. 22-3N-2W SE NAMPA ORIGINAL TX 98728 OF LT 32 BLK 34
02-3N-2W NW TX 03475 LS RD IN S 1/2 NW
... View more
09-30-2019
02:01 PM
|
0
|
8
|
4326
|
|
POST
|
I was able to get the print outs. I still need to get the Legal2 field populated with the results some how. When i add an update cursor i get the following error line 27, in <module>
with arcpy.da.UpdateCursor(recs,["Legal2"]) as cursor:
RuntimeError: 'in_table' is not a table or a featureclass I am a little lost on how to populate the Legal2 field? - with arcpy.da.UpdateCursor(recs,["Legal2"]) as cursor: with arcpy.da.UpdateCursor(recs,["Legal2"]) as cursor: for row in cursor: print results, but they looked like this. ['02362']
['03315', '05857', '05858']
['15022']
['03398']
['5858']
['05857']
['1', '2', 'T72007']
['1']
['2']
[]
[]
[]
[]
[]
['04089']
['04089'] currently have import arcpy, re
recs = r'C:\Temp\Descriptions.shp'
field = 'Legal'
recs = (row[0] for row in arcpy.da.SearchCursor(recs, field))
pattern = re.compile(r"[ ,&]+")
def extract_tax_ids(split_desc):
l = []
b = False
for i in split_desc:
if i in ("TX", "TAX"):
b = True
continue
if b and not i.isalpha():
l.append(i)
else:
b = False
return l
#for rec in recs:
#where = extract_tax_ids(pattern.split(rec))
with arcpy.da.UpdateCursor(recs,["Legal2"]) as cursor:
for row in cursor:
... View more
09-30-2019
09:06 AM
|
0
|
1
|
4326
|
|
POST
|
I have a field with with descriptions and i need to extract the tax numbers from this field and put them into another field in the same layer. Some examples of what i need . 1. 12-5N-5W SW NW SW S & W OF CANAL,, TX 2 IN SWNW LS TX 2-A - I need to extract "TX 2" from this field 2. 23-3N-2W SW 4TH ST TOWNHOMES TX 11271 IN LT 4C BLK 1 - I need to extract "TX 11271" from this row 3. 04-5N-5W SE TAX 3 & TAX 4 IN NWSE - I need to extract "TAX 3, TAX 4" from this row 4. 21-4N-3W SW TX 86, 89, 90 & 93 IN S 1/2 OF SW - I need to exact "TX 86, 89,90 & 93" from this row I currently can extract numbers with the following and i need help to include what i mentioned above. I guess i need to extract everything beginning at TX and before the space before the next alpha characters. fc = r'C:\Temp\Parcels.shp'
with arcpy.da.UpdateCursor(fc,['Legal','Legal2']) as cursor:
for row in cursor:
row[1] = ''.join([str(i) for i in row[0] if i.isdigit()])
cursor.updateRow(row)
... View more
09-27-2019
03:14 PM
|
0
|
14
|
5918
|
|
POST
|
Looking at my data i noticed that the OID@ on both layers where not matching so i had to change the OID@, my apologies. Once i changed the uniqueID and ran the script i get error. line 18, in <module> if [row[1]].strip().lower() != addDict[row[0]].strip().lower(): #if the value associated with those ids do not match AttributeError: 'list' object has no attribute 'strip' code import arcpy
from datetime import datetime as d
startTime = d.now()
fc1 = r'C:\Temp\TaxParcels1.shp'
fc2 = r'C:\Temp\AddresPointsTest.shp'
#build a dictionary of OBJECTID : Address pairs, change OID@ to your uniqueID
addDict = {row[0]:row[1] for row in arcpy.da.SearchCursor(fc1, ['ACCOUNT','SiteAddress'])}
#search through fc2 to see if addresses match based on OBJECTID value
#again, change OID@ to your uniqueID
with arcpy.da.UpdateCursor(fc2, ['Account','SiteAddres','Verifi2']) as cursor:
for row in cursor:
if row[0] in addDict:
if row[1].strip().lower() != addDict[row[0]].strip().lower(): #if the value associated with those ids do not match
row[2] = 'No'
else:
row[2] = 'Match'
cursor.updateRow(row)
del cursor
try:
print '(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')'
except Exception, e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print "Line %i" % tb.tb_lineno
print e.message
... View more
10-05-2017
01:22 PM
|
0
|
2
|
932
|
|
POST
|
tired the following but i get following error: if row[1].strip().lower() != addDict[row[0].strip().lower()]: #if the value associated with those ids do not match AttributeError: 'int' object has no attribute 'strip' if row[1].lower() != addDict[row[0].lower()]: & if row[1].strip().lower() != addDict[row[0].strip().lower()]:
... View more
10-05-2017
07:56 AM
|
0
|
2
|
2890
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-01-2024 07:19 AM | |
| 1 | 07-26-2024 09:38 AM | |
| 1 | 01-08-2024 09:44 AM | |
| 1 | 03-07-2023 11:46 AM | |
| 1 | 11-02-2020 08:24 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-12-2026
12:36 PM
|