How to combine search and update cursor on one table to change valuesDebugging ArcPy script to search, get...

Why not use SQL instead of GraphQL?

Why was the small council so happy for Tyrion to become the Master of Coin?

What do you call a Matrix-like slowdown and camera movement effect?

To string or not to string

How does one intimidate enemies without having the capacity for violence?

TGV timetables / schedules?

Is it unprofessional to ask if a job posting on GlassDoor is real?

Modeling an IPv4 Address

Is it legal for company to use my work email to pretend I still work there?

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

Why do falling prices hurt debtors?

Today is the Center

"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"

Problem of parity - Can we draw a closed path made up of 20 line segments...

Why dont electromagnetic waves interact with each other?

Can a Warlock become Neutral Good?

Example of a continuous function that don't have a continuous extension

Why Is Death Allowed In the Matrix?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Why does Kotter return in Welcome Back Kotter?

Risk of getting Chronic Wasting Disease (CWD) in the United States?

How do I create uniquely male characters?

How to format long polynomial?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?



How to combine search and update cursor on one table to change values


Debugging ArcPy script to search, get value, compare to field names and sum field values?Polygon found with search cursor, but not update cursorCreating a value-counting table with search- and update cursorPython Script to update all feature classes/datasets in gdb with search and update cursor?ArcPy Update Cursor after nested Search Cursor giving tuple assignment error?Error when updating arcpy.SearchCursor to arcpy.da.SearchCursorUsing dictionary and cursors to calculate a field based on values from another table - KeyError [0]Calculating field with ArcPy cursor?Search Cursor Return Field Name If All Rows Contain a ValueSwitching from Nested Search Cursors to Dictionaries






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I'm working a script for drives, I would like to read the values from the "Layer" field, if the values state "D-DRIVE-PAVE-P" then I want the field "SURFACEM" to be ANG if not then GR. This is what I have however I am receiving a syntax error.



import arcpy, os


# Script tool Params
In_Feature= arcpy.GetParameterAsText(0)
Outh_Path = arcpy.GetParameterAsText(1)
Outh_Name = arcpy.GetParameterAsText(2)
MyStatus = arcpy.GetParameterAsText(3)
TranslationTable = arcpy.GetParameterAsText(4)

#################################
#Create an DrivewayArea Shapefile
#################################
MyDGNLayer=In_Feature+'/Polygon'
Outh_Name1="DrivewayArea.shp"
ListOfLayers= ("D-DRIVE-UPAV-P",
"D-DRIVE-PAVE-P"
)
Outh_Filter="Layer in "+ str(ListOfLayers)
MyTable=Outh_Path+"/"+Outh_Name1
arcpy.FeatureClassToFeatureClass_conversion(MyDGNLayer, Outh_Path, Outh_Name1,Outh_Filter)


# Get All field names except shape and FID
field_names = []
fields = arcpy.ListFields(MyTable)
for field in fields:
if field.name=="Shape":
arcpy.AddMessage(field_names)
elif field.name=="FID":
arcpy.AddMessage(field_names)
else:
field_names.append(field.name)


with arcpy.da.SearchCursor(MyTable, ["D-DRIVE-PAVE-P"])
for row in cursor:
D-DRIVE-PAVE-P.add(row[0]

with arcpy.da.UpdateCursor(MyTable, ["Layer", "SURFACEM"]) as cursor:
for row in cursor:
if row[0] in D-DRIVE-PAVE-P:
row[1] = "ANG"
else:
row[1] = "GR"
cursor.updateRow(row)
del cursor


What do I need to do to fix this?










share|improve this question









New contributor




T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0















    I'm working a script for drives, I would like to read the values from the "Layer" field, if the values state "D-DRIVE-PAVE-P" then I want the field "SURFACEM" to be ANG if not then GR. This is what I have however I am receiving a syntax error.



    import arcpy, os


    # Script tool Params
    In_Feature= arcpy.GetParameterAsText(0)
    Outh_Path = arcpy.GetParameterAsText(1)
    Outh_Name = arcpy.GetParameterAsText(2)
    MyStatus = arcpy.GetParameterAsText(3)
    TranslationTable = arcpy.GetParameterAsText(4)

    #################################
    #Create an DrivewayArea Shapefile
    #################################
    MyDGNLayer=In_Feature+'/Polygon'
    Outh_Name1="DrivewayArea.shp"
    ListOfLayers= ("D-DRIVE-UPAV-P",
    "D-DRIVE-PAVE-P"
    )
    Outh_Filter="Layer in "+ str(ListOfLayers)
    MyTable=Outh_Path+"/"+Outh_Name1
    arcpy.FeatureClassToFeatureClass_conversion(MyDGNLayer, Outh_Path, Outh_Name1,Outh_Filter)


    # Get All field names except shape and FID
    field_names = []
    fields = arcpy.ListFields(MyTable)
    for field in fields:
    if field.name=="Shape":
    arcpy.AddMessage(field_names)
    elif field.name=="FID":
    arcpy.AddMessage(field_names)
    else:
    field_names.append(field.name)


    with arcpy.da.SearchCursor(MyTable, ["D-DRIVE-PAVE-P"])
    for row in cursor:
    D-DRIVE-PAVE-P.add(row[0]

    with arcpy.da.UpdateCursor(MyTable, ["Layer", "SURFACEM"]) as cursor:
    for row in cursor:
    if row[0] in D-DRIVE-PAVE-P:
    row[1] = "ANG"
    else:
    row[1] = "GR"
    cursor.updateRow(row)
    del cursor


    What do I need to do to fix this?










    share|improve this question









    New contributor




    T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I'm working a script for drives, I would like to read the values from the "Layer" field, if the values state "D-DRIVE-PAVE-P" then I want the field "SURFACEM" to be ANG if not then GR. This is what I have however I am receiving a syntax error.



      import arcpy, os


      # Script tool Params
      In_Feature= arcpy.GetParameterAsText(0)
      Outh_Path = arcpy.GetParameterAsText(1)
      Outh_Name = arcpy.GetParameterAsText(2)
      MyStatus = arcpy.GetParameterAsText(3)
      TranslationTable = arcpy.GetParameterAsText(4)

      #################################
      #Create an DrivewayArea Shapefile
      #################################
      MyDGNLayer=In_Feature+'/Polygon'
      Outh_Name1="DrivewayArea.shp"
      ListOfLayers= ("D-DRIVE-UPAV-P",
      "D-DRIVE-PAVE-P"
      )
      Outh_Filter="Layer in "+ str(ListOfLayers)
      MyTable=Outh_Path+"/"+Outh_Name1
      arcpy.FeatureClassToFeatureClass_conversion(MyDGNLayer, Outh_Path, Outh_Name1,Outh_Filter)


      # Get All field names except shape and FID
      field_names = []
      fields = arcpy.ListFields(MyTable)
      for field in fields:
      if field.name=="Shape":
      arcpy.AddMessage(field_names)
      elif field.name=="FID":
      arcpy.AddMessage(field_names)
      else:
      field_names.append(field.name)


      with arcpy.da.SearchCursor(MyTable, ["D-DRIVE-PAVE-P"])
      for row in cursor:
      D-DRIVE-PAVE-P.add(row[0]

      with arcpy.da.UpdateCursor(MyTable, ["Layer", "SURFACEM"]) as cursor:
      for row in cursor:
      if row[0] in D-DRIVE-PAVE-P:
      row[1] = "ANG"
      else:
      row[1] = "GR"
      cursor.updateRow(row)
      del cursor


      What do I need to do to fix this?










      share|improve this question









      New contributor




      T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I'm working a script for drives, I would like to read the values from the "Layer" field, if the values state "D-DRIVE-PAVE-P" then I want the field "SURFACEM" to be ANG if not then GR. This is what I have however I am receiving a syntax error.



      import arcpy, os


      # Script tool Params
      In_Feature= arcpy.GetParameterAsText(0)
      Outh_Path = arcpy.GetParameterAsText(1)
      Outh_Name = arcpy.GetParameterAsText(2)
      MyStatus = arcpy.GetParameterAsText(3)
      TranslationTable = arcpy.GetParameterAsText(4)

      #################################
      #Create an DrivewayArea Shapefile
      #################################
      MyDGNLayer=In_Feature+'/Polygon'
      Outh_Name1="DrivewayArea.shp"
      ListOfLayers= ("D-DRIVE-UPAV-P",
      "D-DRIVE-PAVE-P"
      )
      Outh_Filter="Layer in "+ str(ListOfLayers)
      MyTable=Outh_Path+"/"+Outh_Name1
      arcpy.FeatureClassToFeatureClass_conversion(MyDGNLayer, Outh_Path, Outh_Name1,Outh_Filter)


      # Get All field names except shape and FID
      field_names = []
      fields = arcpy.ListFields(MyTable)
      for field in fields:
      if field.name=="Shape":
      arcpy.AddMessage(field_names)
      elif field.name=="FID":
      arcpy.AddMessage(field_names)
      else:
      field_names.append(field.name)


      with arcpy.da.SearchCursor(MyTable, ["D-DRIVE-PAVE-P"])
      for row in cursor:
      D-DRIVE-PAVE-P.add(row[0]

      with arcpy.da.UpdateCursor(MyTable, ["Layer", "SURFACEM"]) as cursor:
      for row in cursor:
      if row[0] in D-DRIVE-PAVE-P:
      row[1] = "ANG"
      else:
      row[1] = "GR"
      cursor.updateRow(row)
      del cursor


      What do I need to do to fix this?







      arcpy






      share|improve this question









      New contributor




      T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 3 mins ago







      T. Tobin













      New contributor




      T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 11 mins ago









      T. TobinT. Tobin

      11




      11




      New contributor




      T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      T. Tobin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          T. Tobin is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318010%2fhow-to-combine-search-and-update-cursor-on-one-table-to-change-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          T. Tobin is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          T. Tobin is a new contributor. Be nice, and check out our Code of Conduct.













          T. Tobin is a new contributor. Be nice, and check out our Code of Conduct.












          T. Tobin is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318010%2fhow-to-combine-search-and-update-cursor-on-one-table-to-change-values%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          Meter-Bus Содержание Параметры шины | Стандартизация |...