3

I have a dataset with a text field ("INL_EL") containing mix formatted values likes {92.066} or 94.461.

I want to make a new numeric field ("INL_EL_N") containing the above values. Tried to write the text values to the numeric field using field calculator but as it was expected it only worked for values liked 94.461 and returned null for values like {92.066}.

Any ideas how it can be achieved?

5
  • 1
    You want to have two values in one numeric field or am I misunderstanding? Are you using a data format that supports list types? Commented May 21, 2022 at 10:21
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Commented May 21, 2022 at 10:31
  • are parens used to indicate negative numbers - ie, (92.066) = -92.066?
    – Llaves
    Commented May 21, 2022 at 14:57
  • @bugmenot123 - I think the example values are examples of formatting and isn't intended to suggest two values in a single entry. Hopefully the OP will clarify this.
    – Llaves
    Commented May 21, 2022 at 14:58
  • 1
    the {} is used from a water solutions program to indicate that the value is computed and not user defined. As Llaves said the numbers are two different attributes and not one. @BERA gave the correct answer that it worked! Thanks!
    – Manos
    Commented May 22, 2022 at 5:01

1 Answer 1

4

regexp_substr( "stringfield", '(-?\\d+\\.?\\d*)')

https://www.tutorialspoint.com/How-to-extract-numbers-from-a-string-in-Python

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.