Python arcpy update cursor loop interrupted










0















This script was made to clean a table of rows that has no counterpart in another table (It must be made via arcpy because the table is a feature class with archiving enabled, from ESRI). I'm testing this script in production, so, instead actually erasing the rows, I'm just using a counter. However, when the counter 'excluidos' is about value 310000, the script just stops. There is some memory limit in arcpy update cursor? (normally I get some python memory error message, which is not the case here) Or there is some logic problem here that I'm missing?



# -*- encoding: utf-8 -*-
import os.path, sys, time
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from arcpy import da

pasta = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', 'modelos'))

fc = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.fis_vistorias_aia_tcra'
fc2 = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.tb_fis_vistorias_aia_tcra'
workspace = os.path.dirname(fc)

campos = [
"NIS"
,"Sigla"]

campos2 = ["NIS", "DataElabRTV"]

print str(time.strftime('%x %X'))
print 'Iniciando busca de registros no workspace: ' + fc2

lista =
listIg =

with da.SearchCursor(fc2, (campos2)) as sc:
for row in sc:
if row[0] <> None:
lista.append(row[0])

print str(time.strftime('%x %X'))
print 'Iniciando exclusao de registros no workspace: ' + fc

try:
edit = da.Editor(workspace)
print str(time.strftime('%x %X'))
print 'Iniciando edicao.'
edit.startEditing(False, False) #undo/multiuser
print str(time.strftime('%x %X'))
print 'Iniciando operacao.'
edit.startOperation()
except Exception as e:
print e
sys.exit(0)

print str(time.strftime('%x %X'))
print 'Iniciando exclusao.'
excluidos = 0
ignorados = 0
multiplo = 100000
try:
with da.UpdateCursor(fc, (campos)) as cursorExc:
for row in cursorExc:
if row[0] <> None:
verifExcec = False
for reg in lista:
if reg == int(row[0]):
verifExcec = True
if verifExcec:
listIg.append(reg)
ignorados += 1
continue
else:
#cursorExc.deleteRow()
excluidos += 1
else:
ignorados += 1
#verifica se o contador e igual ao multiplo definido para emitir o aviso
if (excluidos % multiplo == 0):
print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."


except Exception as e:
print e

print str(time.strftime('%x %X'))
print str(excluidos) + ' registros excluidos.'

print str(time.strftime('%x %X'))
print str(ignorados) + ' registros ignorados.'

try:
# Stop the edit operation.
print str(time.strftime('%x %X'))
print 'Encerrando operacao.'
edit.stopOperation()

# Stop the edit session and save the changes
print str(time.strftime('%x %X'))
print 'Encerrando edicao.'
edit.stopEditing(True)
except Exception as e:
print e

listIg.sort()
for nis in listIg:
print nis









share|improve this question


























    0















    This script was made to clean a table of rows that has no counterpart in another table (It must be made via arcpy because the table is a feature class with archiving enabled, from ESRI). I'm testing this script in production, so, instead actually erasing the rows, I'm just using a counter. However, when the counter 'excluidos' is about value 310000, the script just stops. There is some memory limit in arcpy update cursor? (normally I get some python memory error message, which is not the case here) Or there is some logic problem here that I'm missing?



    # -*- encoding: utf-8 -*-
    import os.path, sys, time
    sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

    from arcpy import da

    pasta = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', 'modelos'))

    fc = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.fis_vistorias_aia_tcra'
    fc2 = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.tb_fis_vistorias_aia_tcra'
    workspace = os.path.dirname(fc)

    campos = [
    "NIS"
    ,"Sigla"]

    campos2 = ["NIS", "DataElabRTV"]

    print str(time.strftime('%x %X'))
    print 'Iniciando busca de registros no workspace: ' + fc2

    lista =
    listIg =

    with da.SearchCursor(fc2, (campos2)) as sc:
    for row in sc:
    if row[0] <> None:
    lista.append(row[0])

    print str(time.strftime('%x %X'))
    print 'Iniciando exclusao de registros no workspace: ' + fc

    try:
    edit = da.Editor(workspace)
    print str(time.strftime('%x %X'))
    print 'Iniciando edicao.'
    edit.startEditing(False, False) #undo/multiuser
    print str(time.strftime('%x %X'))
    print 'Iniciando operacao.'
    edit.startOperation()
    except Exception as e:
    print e
    sys.exit(0)

    print str(time.strftime('%x %X'))
    print 'Iniciando exclusao.'
    excluidos = 0
    ignorados = 0
    multiplo = 100000
    try:
    with da.UpdateCursor(fc, (campos)) as cursorExc:
    for row in cursorExc:
    if row[0] <> None:
    verifExcec = False
    for reg in lista:
    if reg == int(row[0]):
    verifExcec = True
    if verifExcec:
    listIg.append(reg)
    ignorados += 1
    continue
    else:
    #cursorExc.deleteRow()
    excluidos += 1
    else:
    ignorados += 1
    #verifica se o contador e igual ao multiplo definido para emitir o aviso
    if (excluidos % multiplo == 0):
    print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."


    except Exception as e:
    print e

    print str(time.strftime('%x %X'))
    print str(excluidos) + ' registros excluidos.'

    print str(time.strftime('%x %X'))
    print str(ignorados) + ' registros ignorados.'

    try:
    # Stop the edit operation.
    print str(time.strftime('%x %X'))
    print 'Encerrando operacao.'
    edit.stopOperation()

    # Stop the edit session and save the changes
    print str(time.strftime('%x %X'))
    print 'Encerrando edicao.'
    edit.stopEditing(True)
    except Exception as e:
    print e

    listIg.sort()
    for nis in listIg:
    print nis









    share|improve this question
























      0












      0








      0








      This script was made to clean a table of rows that has no counterpart in another table (It must be made via arcpy because the table is a feature class with archiving enabled, from ESRI). I'm testing this script in production, so, instead actually erasing the rows, I'm just using a counter. However, when the counter 'excluidos' is about value 310000, the script just stops. There is some memory limit in arcpy update cursor? (normally I get some python memory error message, which is not the case here) Or there is some logic problem here that I'm missing?



      # -*- encoding: utf-8 -*-
      import os.path, sys, time
      sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

      from arcpy import da

      pasta = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', 'modelos'))

      fc = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.fis_vistorias_aia_tcra'
      fc2 = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.tb_fis_vistorias_aia_tcra'
      workspace = os.path.dirname(fc)

      campos = [
      "NIS"
      ,"Sigla"]

      campos2 = ["NIS", "DataElabRTV"]

      print str(time.strftime('%x %X'))
      print 'Iniciando busca de registros no workspace: ' + fc2

      lista =
      listIg =

      with da.SearchCursor(fc2, (campos2)) as sc:
      for row in sc:
      if row[0] <> None:
      lista.append(row[0])

      print str(time.strftime('%x %X'))
      print 'Iniciando exclusao de registros no workspace: ' + fc

      try:
      edit = da.Editor(workspace)
      print str(time.strftime('%x %X'))
      print 'Iniciando edicao.'
      edit.startEditing(False, False) #undo/multiuser
      print str(time.strftime('%x %X'))
      print 'Iniciando operacao.'
      edit.startOperation()
      except Exception as e:
      print e
      sys.exit(0)

      print str(time.strftime('%x %X'))
      print 'Iniciando exclusao.'
      excluidos = 0
      ignorados = 0
      multiplo = 100000
      try:
      with da.UpdateCursor(fc, (campos)) as cursorExc:
      for row in cursorExc:
      if row[0] <> None:
      verifExcec = False
      for reg in lista:
      if reg == int(row[0]):
      verifExcec = True
      if verifExcec:
      listIg.append(reg)
      ignorados += 1
      continue
      else:
      #cursorExc.deleteRow()
      excluidos += 1
      else:
      ignorados += 1
      #verifica se o contador e igual ao multiplo definido para emitir o aviso
      if (excluidos % multiplo == 0):
      print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."


      except Exception as e:
      print e

      print str(time.strftime('%x %X'))
      print str(excluidos) + ' registros excluidos.'

      print str(time.strftime('%x %X'))
      print str(ignorados) + ' registros ignorados.'

      try:
      # Stop the edit operation.
      print str(time.strftime('%x %X'))
      print 'Encerrando operacao.'
      edit.stopOperation()

      # Stop the edit session and save the changes
      print str(time.strftime('%x %X'))
      print 'Encerrando edicao.'
      edit.stopEditing(True)
      except Exception as e:
      print e

      listIg.sort()
      for nis in listIg:
      print nis









      share|improve this question














      This script was made to clean a table of rows that has no counterpart in another table (It must be made via arcpy because the table is a feature class with archiving enabled, from ESRI). I'm testing this script in production, so, instead actually erasing the rows, I'm just using a counter. However, when the counter 'excluidos' is about value 310000, the script just stops. There is some memory limit in arcpy update cursor? (normally I get some python memory error message, which is not the case here) Or there is some logic problem here that I'm missing?



      # -*- encoding: utf-8 -*-
      import os.path, sys, time
      sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

      from arcpy import da

      pasta = os.path.abspath(os.path.join( os.path.dirname(__file__), '..', 'modelos'))

      fc = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.fis_vistorias_aia_tcra'
      fc2 = 'Database Connections/geodados em arcgissql01.sde/geodados.sigamgeo.tb_fis_vistorias_aia_tcra'
      workspace = os.path.dirname(fc)

      campos = [
      "NIS"
      ,"Sigla"]

      campos2 = ["NIS", "DataElabRTV"]

      print str(time.strftime('%x %X'))
      print 'Iniciando busca de registros no workspace: ' + fc2

      lista =
      listIg =

      with da.SearchCursor(fc2, (campos2)) as sc:
      for row in sc:
      if row[0] <> None:
      lista.append(row[0])

      print str(time.strftime('%x %X'))
      print 'Iniciando exclusao de registros no workspace: ' + fc

      try:
      edit = da.Editor(workspace)
      print str(time.strftime('%x %X'))
      print 'Iniciando edicao.'
      edit.startEditing(False, False) #undo/multiuser
      print str(time.strftime('%x %X'))
      print 'Iniciando operacao.'
      edit.startOperation()
      except Exception as e:
      print e
      sys.exit(0)

      print str(time.strftime('%x %X'))
      print 'Iniciando exclusao.'
      excluidos = 0
      ignorados = 0
      multiplo = 100000
      try:
      with da.UpdateCursor(fc, (campos)) as cursorExc:
      for row in cursorExc:
      if row[0] <> None:
      verifExcec = False
      for reg in lista:
      if reg == int(row[0]):
      verifExcec = True
      if verifExcec:
      listIg.append(reg)
      ignorados += 1
      continue
      else:
      #cursorExc.deleteRow()
      excluidos += 1
      else:
      ignorados += 1
      #verifica se o contador e igual ao multiplo definido para emitir o aviso
      if (excluidos % multiplo == 0):
      print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."


      except Exception as e:
      print e

      print str(time.strftime('%x %X'))
      print str(excluidos) + ' registros excluidos.'

      print str(time.strftime('%x %X'))
      print str(ignorados) + ' registros ignorados.'

      try:
      # Stop the edit operation.
      print str(time.strftime('%x %X'))
      print 'Encerrando operacao.'
      edit.stopOperation()

      # Stop the edit session and save the changes
      print str(time.strftime('%x %X'))
      print 'Encerrando edicao.'
      edit.stopEditing(True)
      except Exception as e:
      print e

      listIg.sort()
      for nis in listIg:
      print nis






      python-2.7 arcpy






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 16:07









      LucasLucas

      94




      94






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I think the limitation is on arcpy, so I should have made the question at GIS Stack Exchange. Anyway, I 'resolved' the issue with a much slower solution, starting and stopping edition for each exclusion:



          print str(time.strftime('%x %X'))
          print 'Iniciando busca de registros no workspace: ' + fc2

          listAIA =
          listVist =
          listIg =
          adicionados = 0
          ignorados = 0

          with da.SearchCursor(fc2, (campos2)) as sc:
          for row in sc:
          if row[0] <> None:
          listVist.append(row[0])

          with da.SearchCursor(fc, (campos)) as sc1:
          for row in sc1:
          verifExcec = False
          if row[0] <> None:
          for vist in listVist:
          if int(row[0]) == vist:
          verifExcec = True
          if verifExcec:
          ignorados += 1
          listIg.append(row[0])
          continue
          else:
          listAIA.append(row[0])
          adicionados += 1
          else:
          ignorados += 1
          listIg.append(row[0])

          print str(time.strftime('%x %X'))
          print 'Iniciando exclusao de registros no workspace: ' + fc

          col_1 = 'NIS'
          excluidos = 0
          multiplo = 100000

          for reg in listAIA:
          expressao = '"' + col_1 + '" = ' + str(reg)
          try:
          edit = da.Editor(workspace)
          edit.startEditing(False, False) #undo/multiuser
          edit.startOperation()
          except Exception as e:
          print e
          sys.exit(0)

          try:
          with da.UpdateCursor(fc, (campos), expressao) as cursorExc:
          for row in cursorExc:
          #cursorExc.deleteRow()
          excluidos += 1
          print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

          except Exception as e:
          print e

          try:
          # Stop the edit operation.
          edit.stopOperation()
          # Stop the edit session and save the changes
          edit.stopEditing(True)
          except Exception as e:
          print e

          if (excluidos % multiplo == 0):
          print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

          print str(time.strftime('%x %X'))
          print str(excluidos) + ' registros excluidos.'

          print str(time.strftime('%x %X'))
          print str(ignorados) + ' registros ignorados.'





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285009%2fpython-arcpy-update-cursor-loop-interrupted%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I think the limitation is on arcpy, so I should have made the question at GIS Stack Exchange. Anyway, I 'resolved' the issue with a much slower solution, starting and stopping edition for each exclusion:



            print str(time.strftime('%x %X'))
            print 'Iniciando busca de registros no workspace: ' + fc2

            listAIA =
            listVist =
            listIg =
            adicionados = 0
            ignorados = 0

            with da.SearchCursor(fc2, (campos2)) as sc:
            for row in sc:
            if row[0] <> None:
            listVist.append(row[0])

            with da.SearchCursor(fc, (campos)) as sc1:
            for row in sc1:
            verifExcec = False
            if row[0] <> None:
            for vist in listVist:
            if int(row[0]) == vist:
            verifExcec = True
            if verifExcec:
            ignorados += 1
            listIg.append(row[0])
            continue
            else:
            listAIA.append(row[0])
            adicionados += 1
            else:
            ignorados += 1
            listIg.append(row[0])

            print str(time.strftime('%x %X'))
            print 'Iniciando exclusao de registros no workspace: ' + fc

            col_1 = 'NIS'
            excluidos = 0
            multiplo = 100000

            for reg in listAIA:
            expressao = '"' + col_1 + '" = ' + str(reg)
            try:
            edit = da.Editor(workspace)
            edit.startEditing(False, False) #undo/multiuser
            edit.startOperation()
            except Exception as e:
            print e
            sys.exit(0)

            try:
            with da.UpdateCursor(fc, (campos), expressao) as cursorExc:
            for row in cursorExc:
            #cursorExc.deleteRow()
            excluidos += 1
            print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

            except Exception as e:
            print e

            try:
            # Stop the edit operation.
            edit.stopOperation()
            # Stop the edit session and save the changes
            edit.stopEditing(True)
            except Exception as e:
            print e

            if (excluidos % multiplo == 0):
            print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

            print str(time.strftime('%x %X'))
            print str(excluidos) + ' registros excluidos.'

            print str(time.strftime('%x %X'))
            print str(ignorados) + ' registros ignorados.'





            share|improve this answer



























              0














              I think the limitation is on arcpy, so I should have made the question at GIS Stack Exchange. Anyway, I 'resolved' the issue with a much slower solution, starting and stopping edition for each exclusion:



              print str(time.strftime('%x %X'))
              print 'Iniciando busca de registros no workspace: ' + fc2

              listAIA =
              listVist =
              listIg =
              adicionados = 0
              ignorados = 0

              with da.SearchCursor(fc2, (campos2)) as sc:
              for row in sc:
              if row[0] <> None:
              listVist.append(row[0])

              with da.SearchCursor(fc, (campos)) as sc1:
              for row in sc1:
              verifExcec = False
              if row[0] <> None:
              for vist in listVist:
              if int(row[0]) == vist:
              verifExcec = True
              if verifExcec:
              ignorados += 1
              listIg.append(row[0])
              continue
              else:
              listAIA.append(row[0])
              adicionados += 1
              else:
              ignorados += 1
              listIg.append(row[0])

              print str(time.strftime('%x %X'))
              print 'Iniciando exclusao de registros no workspace: ' + fc

              col_1 = 'NIS'
              excluidos = 0
              multiplo = 100000

              for reg in listAIA:
              expressao = '"' + col_1 + '" = ' + str(reg)
              try:
              edit = da.Editor(workspace)
              edit.startEditing(False, False) #undo/multiuser
              edit.startOperation()
              except Exception as e:
              print e
              sys.exit(0)

              try:
              with da.UpdateCursor(fc, (campos), expressao) as cursorExc:
              for row in cursorExc:
              #cursorExc.deleteRow()
              excluidos += 1
              print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

              except Exception as e:
              print e

              try:
              # Stop the edit operation.
              edit.stopOperation()
              # Stop the edit session and save the changes
              edit.stopEditing(True)
              except Exception as e:
              print e

              if (excluidos % multiplo == 0):
              print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

              print str(time.strftime('%x %X'))
              print str(excluidos) + ' registros excluidos.'

              print str(time.strftime('%x %X'))
              print str(ignorados) + ' registros ignorados.'





              share|improve this answer

























                0












                0








                0







                I think the limitation is on arcpy, so I should have made the question at GIS Stack Exchange. Anyway, I 'resolved' the issue with a much slower solution, starting and stopping edition for each exclusion:



                print str(time.strftime('%x %X'))
                print 'Iniciando busca de registros no workspace: ' + fc2

                listAIA =
                listVist =
                listIg =
                adicionados = 0
                ignorados = 0

                with da.SearchCursor(fc2, (campos2)) as sc:
                for row in sc:
                if row[0] <> None:
                listVist.append(row[0])

                with da.SearchCursor(fc, (campos)) as sc1:
                for row in sc1:
                verifExcec = False
                if row[0] <> None:
                for vist in listVist:
                if int(row[0]) == vist:
                verifExcec = True
                if verifExcec:
                ignorados += 1
                listIg.append(row[0])
                continue
                else:
                listAIA.append(row[0])
                adicionados += 1
                else:
                ignorados += 1
                listIg.append(row[0])

                print str(time.strftime('%x %X'))
                print 'Iniciando exclusao de registros no workspace: ' + fc

                col_1 = 'NIS'
                excluidos = 0
                multiplo = 100000

                for reg in listAIA:
                expressao = '"' + col_1 + '" = ' + str(reg)
                try:
                edit = da.Editor(workspace)
                edit.startEditing(False, False) #undo/multiuser
                edit.startOperation()
                except Exception as e:
                print e
                sys.exit(0)

                try:
                with da.UpdateCursor(fc, (campos), expressao) as cursorExc:
                for row in cursorExc:
                #cursorExc.deleteRow()
                excluidos += 1
                print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

                except Exception as e:
                print e

                try:
                # Stop the edit operation.
                edit.stopOperation()
                # Stop the edit session and save the changes
                edit.stopEditing(True)
                except Exception as e:
                print e

                if (excluidos % multiplo == 0):
                print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

                print str(time.strftime('%x %X'))
                print str(excluidos) + ' registros excluidos.'

                print str(time.strftime('%x %X'))
                print str(ignorados) + ' registros ignorados.'





                share|improve this answer













                I think the limitation is on arcpy, so I should have made the question at GIS Stack Exchange. Anyway, I 'resolved' the issue with a much slower solution, starting and stopping edition for each exclusion:



                print str(time.strftime('%x %X'))
                print 'Iniciando busca de registros no workspace: ' + fc2

                listAIA =
                listVist =
                listIg =
                adicionados = 0
                ignorados = 0

                with da.SearchCursor(fc2, (campos2)) as sc:
                for row in sc:
                if row[0] <> None:
                listVist.append(row[0])

                with da.SearchCursor(fc, (campos)) as sc1:
                for row in sc1:
                verifExcec = False
                if row[0] <> None:
                for vist in listVist:
                if int(row[0]) == vist:
                verifExcec = True
                if verifExcec:
                ignorados += 1
                listIg.append(row[0])
                continue
                else:
                listAIA.append(row[0])
                adicionados += 1
                else:
                ignorados += 1
                listIg.append(row[0])

                print str(time.strftime('%x %X'))
                print 'Iniciando exclusao de registros no workspace: ' + fc

                col_1 = 'NIS'
                excluidos = 0
                multiplo = 100000

                for reg in listAIA:
                expressao = '"' + col_1 + '" = ' + str(reg)
                try:
                edit = da.Editor(workspace)
                edit.startEditing(False, False) #undo/multiuser
                edit.startOperation()
                except Exception as e:
                print e
                sys.exit(0)

                try:
                with da.UpdateCursor(fc, (campos), expressao) as cursorExc:
                for row in cursorExc:
                #cursorExc.deleteRow()
                excluidos += 1
                print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

                except Exception as e:
                print e

                try:
                # Stop the edit operation.
                edit.stopOperation()
                # Stop the edit session and save the changes
                edit.stopEditing(True)
                except Exception as e:
                print e

                if (excluidos % multiplo == 0):
                print u"0 - 1 ".format(time.strftime('%x %X'), excluidos) + u" registros excluídos até o momento."

                print str(time.strftime('%x %X'))
                print str(excluidos) + ' registros excluidos.'

                print str(time.strftime('%x %X'))
                print str(ignorados) + ' registros ignorados.'






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 14 '18 at 12:08









                LucasLucas

                94




                94



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • 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%2fstackoverflow.com%2fquestions%2f53285009%2fpython-arcpy-update-cursor-loop-interrupted%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







                    這個網誌中的熱門文章

                    What does pagestruct do in Eviews?

                    Dutch intervention in Lombok and Karangasem

                    Channel Islands