0

I'm writing a script for ArcMap

what I want is

rows = arcpy.UpdateCursor(featureClass) #open a cursor from data source
row = rows.next()
AddressFieldName = "row.ADD_FULL"
while row:
    s = AddressFieldName 

but it doesn't work. originally

s = row.Add_FULL #Add_FULL is field column name

What can I do to solve this?

7
  • what you expect and what actually doesn't work? any errors? what is your current output? Commented Jul 20, 2015 at 14:15
  • Parsing error SyntaxError: invalid syntax when I use s = row + . + AddressFieldName and tried other ways that I could think of but about same Commented Jul 20, 2015 at 14:34
  • Please provide full error log (edit your question with adding log). Also let me know what is ADD_FULL method (I can't find description in google) and why you define s in 3 different ways: as string- "row.ADD_FULL", as method applying to row - s = row.Add_FULL (what is correct form ADD_FULL or Add_FULL???) and in some kind of mystery way- s = row + . + AddressFieldName? Commented Jul 20, 2015 at 16:01
  • I got this using s= row.getValue(AddressFieldName) Commented Jul 20, 2015 at 16:19
  • This is the 4th definition of s :) Can you make required corrections to your question using following tips: specify input, your current code, error log, expected output... For now your question make no sense Commented Jul 20, 2015 at 20:21

1 Answer 1

1

I am guessing that you do want to extract the field names of a Feature class and maybe the field values as well. You could try the following codesnippet:

rows = arcpy.SearchCursor(sourceFeatureClass)
fields = arcpy.ListFields(sourceFeatureClass)
fieldnames = ""
for field in fields:
    fieldnames += field.name
fulldata=""
for row in rows:
    data = ""
    for field in fields:
        data += row.getValue(field.name)
    fulldata += data

This way you do get all your fieldnames in "fields" and the data either per row in "data" or the all data of the featureclass in "fulldata"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.