4

What is the simplest way to retrieve each value to a new column from a string with values separated by commas in QGIS?

My data look kind of like this:

STRING
-----------
wp1,wp2,wp3

but I want

STRING1 | STRING2 | STRING3
--------|---------|--------
 wp1    | wp2     | wp3
2
  • What did you try?
    – Erik
    Commented Jan 12, 2022 at 15:34
  • 4
    Create three new fields with field calculator and this expression: string_to_array(string)[0] for string 1 and replace [0] with [1] for string 2 etc.
    – Babel
    Commented Jan 12, 2022 at 15:40

1 Answer 1

4

You can use "Vector table > Refactor fields" tool.

In the tool window:

  • Add three new fields.
  • Populate the text boxes as in the image:
    Expression: string_to_array(string)[0]

enter image description here

Result:

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.