3

I have a problem to add a *.tab file as delimitedtext layer in QGIS 3.

uri = ("file:///{}?"
               "&delimiter={}"
               "&xField={}"
               "&yField={}"
               "&crs={}"
               "&decimal").format(tab_text,
                                        "\t",
                                        "Rechtswert",
                                        "Hochwert",
                                        "EPSG:31468",",")
vlayer = QgsVectorLayer(uri, "layer", "delimitedtext")

If I test the layer with .isValid I get a False. Did I have to name more variables?

1 Answer 1

2

Just add add another backslash when specifying tabs:

"\\t"
5
  • Thats not working because my delimiter is a tab. If I try double backslash i get "\t" as delimiter
    – RickJames
    Commented Jun 6, 2018 at 15:08
  • @RickJames - Yes, a single slash is shown for me in the layer's information but to import it, I had to use double slashes. Tested on QGIS 3.0.1 for Win 7 64-bit.
    – Joseph
    Commented Jun 6, 2018 at 15:13
  • 1
    you are right it worked. The other problem was my coordinate system.
    – RickJames
    Commented Jun 6, 2018 at 15:25
  • @RickJames - Glad it worked :)
    – Joseph
    Commented Jun 6, 2018 at 15:27
  • Why the need to use \\t as oppose to \t. Commented Dec 7, 2022 at 10:54

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.