[GIS] How to one solve the “Handle Unavailable Layers” error on a csv file in QGIS

macqgis

I've been working on this project for over a year and I have never had any substantial problem. Two days ago I was working on the project and everything worked fine. Today, when I try to load the project, I get the following:

enter image description here

The layer in question depicts points on my map. If I click on "Keep Unavailable Layers" and hover my mouse over the layer in question in the layers pane, I get the following message: Unavailable layer! Layer data source could not be found. Click to select a new data source.

enter image description here

I click and select the exact same data source, i.e. I "remind" QGIS where the .csv file is located, but then almost nothing seems to happen, apart from the layer's symbol changing from three dots to a cute cinderblock. The points on my map do not come back.
enter image description here
I am certain that neither the .qgs project file nor the .csv have been moved. Nor have I updated my operating system.
The problem surfaced with QGIS 3.10 running on MacOS 11.1 (Big Sur), but I have tried with QGIS 3.16 too and I get the same error. The source file is readable by QGIS, because I can create a new layer with the same csv file and it works.

Why is this happening? How can I get my layer back?

Edit: If I try to copy the style (Styles > Copy Style > All styles categories) of the cinderblock layer to a newly created layer with the same source file (Styles > Paste style > All styles), I get the following error:

enter image description here

But if I copy the style before the old layer becomes a cinderblock (i.e. before clicking "click here to select a new data source"), I do get back my old points…

enter image description here
…but I don't get back the callout lines (the lines between the labels and the points). Before the problem, it looked like this (from a PDF file):

enter image description here

If I try to zoom in on this region in QGIS…

enter image description here

…I get this:
enter image description here

Meanwhile the callouts on the new layer are defined like this (it used to say 0 mm of minimum length, I changed it to 3mm to no avail, nothing changes).

enter image description here

The content of the non-working Datasource (the one in the first screenshot) is file:../../../Articles/[Some folder name]/[some file name].csv?type=csv&delimiter=%5Ct;&detectTypes=yes&xField=longitude&yField=latitude&crs=EPSG:4326&spatialIndex=no&subsetIndex=no&watchFile=no The content of the Datasource in the working layer is: file:///[Some path]/[Some file name].csv?type=csv&maxFields=10000&detectTypes=yes&xField=longitude&yField=latitude&crs=EPSG:4326&spatialIndex=no&subsetIndex=no&watchFile=no

The delimiters appear different in these two versions (%5Ct; in the first, and not mentioned in the second so presumably commas). But when I try to paste the working Datasource path in the problematic layer, the problem is not resolved.

Best Answer

As a workaraound, you can load the CSV as a new layer and replace the old (broken) layer with this new one. You mention that you have no problem to load the same CSV as a new layer. You could just copy/paste all styling information from the old to the new one. Be sure to select All Style Categories.

To see your callout lines, increase the distance of your labels: your callouts are there, but the distance of the label from the point symbol is too small to be seen.

Related Question