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?

JGH
44.4k3 gold badges49 silver badges95 bronze badges
asked Jun 5, 2018 at 14:39

1 Answer 1

2

Just add add another backslash when specifying tabs:

"\\t"
answered Jun 6, 2018 at 13:36
5
  • Thats not working because my delimiter is a tab. If I try double backslash i get "\t" as delimiter 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. Commented Jun 6, 2018 at 15:13
  • 1
    you are right it worked. The other problem was my coordinate system. Commented Jun 6, 2018 at 15:25
  • @RickJames - Glad it worked :) 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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.