I have always used tab-delimited text files to bring Excel data into QGIS. By default, these are saved by Excel with the suffix".txt". Mostly there is no problem opening these and I have hundreds spread across different projects, many with complex filters. Every so often, however, a project will open with errors on all or some of these. They are marked as bad layers even though nothing has changed - and I can create another project and open them perfectly well.
In comparing the description string in layer properties or the data source in the "Handle Unavailable Layers" dialogue box, the successful ones say "delimiter=%5Ct" (I have no idea why) while the ones marked as bad layers say "delimiter=/t". The browse function in handle bad layers doesn't do anything with these, and I cannot correct using repair data source or the Change Data Source plugin, because neither will recognize a ".txt" file as a valid input.
I can force all the bad layers to work correctly by manually editing the string to say "delimiter=%5Ct". I can then successfully query, display and interrogate them for the duration of the session. However, when I save the project and re-open it, the problematic part of the string has changed back to "delimiter=/t" on all the layers I corrected, and so these fail again to open properly.
Is there a work-around here except renaming all my text files as ".csv" files or re-exporting then as comma-delimited ".csv" files? I'm using 3.24.1 on Windows 10.
EDIT (1 April but not April fools): This is not so much an answer but a work-around. If I open a second copy of the delimited file and fully specify file format - "custom delimiter" and "tab" (which seems intuitive and is what I regularly do) then the file opens in the first session but reports as a bad layer in all subsequent sessions.
HOWEVER, if I open it as a delimited file after unchecking the "tab" delimited or even specifically turning off "custom delimiters", then it not only correctly recognizes the tabs and loads the file, but also loads those files without errors in subsequent sessions. A bug perhaps?
EDIT 2 On 4 July 22. @grandebooz seems to be on the right track but it is still only half the problem. My solution described in the first edit has been working without error for the last few weeks. However, I upgraded to 3.26.0 and yesterday saved the project in that format for the first time. On next opening, EVERY one of the problem files gave the error on opening. I edited the source to place "file:" in front of the string as suggested, and every one promptly opened without error. However, even after re-saving, every one continues to give an opening error, which can be resolved by editing the source as described.
EDIT 3 The Plugin mentioned in the Github link below resolves the issue at least in a temporary sense.