Search and Replace text in ALL FIELDS in QGIS 3MultiLine field-name label referencing in PyQGIS?Search...

How to draw the figure with four pentagons?

Neighboring nodes in the network

1960's book about a plague that kills all white people

In Romance of the Three Kingdoms why do people still use bamboo sticks when papers are already invented?

Forgetting the musical notes while performing in concert

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

Is it possible to create light that imparts a greater proportion of its energy as momentum rather than heat?

Western buddy movie with a supernatural twist where a woman turns into an eagle at the end

Could gravitational lensing be used to protect a spaceship from a laser?

What mechanic is there to disable a threat instead of killing it?

Anagram holiday

How to prevent "they're falling in love" trope

Fully-Firstable Anagram Sets

Can a virus destroy the BIOS of a modern computer?

Assassin's bullet with mercury

Why is Collection not simply treated as Collection<?>

Infinite Abelian subgroup of infinite non Abelian group example

Why can't we play rap on piano?

Should I tell management that I intend to leave due to bad software development practices?

How can I make my BBEG immortal short of making them a Lich or Vampire?

A reference to a well-known characterization of scattered compact spaces

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

How do I write bicross product symbols in latex?

Theorems that impeded progress



Search and Replace text in ALL FIELDS in QGIS 3


MultiLine field-name label referencing in PyQGIS?Search Shapefile and return ExtentsDelete all fields with the string “RAWI” using QGIS PythonHow to replace QGIS featureAtId() with getfeatures()?How to iterate through all fields, and all records in each field with GDAL/OGRQGIS Python Postcode Search ErrorPython Scripting in QGIS to add features and select them?Python QGIS 2.18 to QGIS 3 : Shp file attribute joins and how do i specify the join fields?Adding processed features and layer to QGIS 3 projectQGIS Processing Script to Create and Add CSV Layer






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







0















I want to replace a string in ALL FIELDS / Columns of table without having to do it using field calculator in every field manually using replace( "RoadName1" ,'Wharf','WharfXXX')



I have



layer = iface.activeLayer()
searchText = "Wharf"
replaceText = "WharfXXX"
for field in layer.fields():
print (field.name())
for feature in layer.getFeatures():
inText=str(feature[field.name()])
#print (inText)
if searchText in inText:
QgsStringReplacement(inText,replaceText, False, False)
print ("Replaced %s with %s" %(inText,replaceText))


It seems to work but I am not seeing any changes in the dataset.



I can't find any example implementations of https://qgis.org/api/classQgsStringReplacement.htmlenter image description here



Does this function do what I think it's supposed to -i.e. replace text when it matches?









share





























    0















    I want to replace a string in ALL FIELDS / Columns of table without having to do it using field calculator in every field manually using replace( "RoadName1" ,'Wharf','WharfXXX')



    I have



    layer = iface.activeLayer()
    searchText = "Wharf"
    replaceText = "WharfXXX"
    for field in layer.fields():
    print (field.name())
    for feature in layer.getFeatures():
    inText=str(feature[field.name()])
    #print (inText)
    if searchText in inText:
    QgsStringReplacement(inText,replaceText, False, False)
    print ("Replaced %s with %s" %(inText,replaceText))


    It seems to work but I am not seeing any changes in the dataset.



    I can't find any example implementations of https://qgis.org/api/classQgsStringReplacement.htmlenter image description here



    Does this function do what I think it's supposed to -i.e. replace text when it matches?









    share

























      0












      0








      0








      I want to replace a string in ALL FIELDS / Columns of table without having to do it using field calculator in every field manually using replace( "RoadName1" ,'Wharf','WharfXXX')



      I have



      layer = iface.activeLayer()
      searchText = "Wharf"
      replaceText = "WharfXXX"
      for field in layer.fields():
      print (field.name())
      for feature in layer.getFeatures():
      inText=str(feature[field.name()])
      #print (inText)
      if searchText in inText:
      QgsStringReplacement(inText,replaceText, False, False)
      print ("Replaced %s with %s" %(inText,replaceText))


      It seems to work but I am not seeing any changes in the dataset.



      I can't find any example implementations of https://qgis.org/api/classQgsStringReplacement.htmlenter image description here



      Does this function do what I think it's supposed to -i.e. replace text when it matches?









      share














      I want to replace a string in ALL FIELDS / Columns of table without having to do it using field calculator in every field manually using replace( "RoadName1" ,'Wharf','WharfXXX')



      I have



      layer = iface.activeLayer()
      searchText = "Wharf"
      replaceText = "WharfXXX"
      for field in layer.fields():
      print (field.name())
      for feature in layer.getFeatures():
      inText=str(feature[field.name()])
      #print (inText)
      if searchText in inText:
      QgsStringReplacement(inText,replaceText, False, False)
      print ("Replaced %s with %s" %(inText,replaceText))


      It seems to work but I am not seeing any changes in the dataset.



      I can't find any example implementations of https://qgis.org/api/classQgsStringReplacement.htmlenter image description here



      Does this function do what I think it's supposed to -i.e. replace text when it matches?







      pyqgis pyqgis-3 qgsstringreplacement





      share












      share










      share



      share










      asked 3 mins ago









      GeorgeCGeorgeC

      2,90732981




      2,90732981






















          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317855%2fsearch-and-replace-text-in-all-fields-in-qgis-3%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
















          draft saved

          draft discarded




















































          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%2f317855%2fsearch-and-replace-text-in-all-fields-in-qgis-3%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

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

          Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

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