Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataview DQL block cannot parse tsv data when the file's extension is .tsv, but can do so when the same data is in a .csv file #2540

Open
vivvienne opened this issue Mar 11, 2025 · 3 comments
Labels
bug Something isn't working. documentation Improvements or additions to documentation DQL Query language UX, issues, and features.

Comments

@vivvienne
Copy link

What happened?

As stated in the title, when tsv data is stored in a .tsv file, the function csv() (for importing csv data) in a dataview DQL block cannot parse that file, but when the same data is stored in a .csv file, it can parse that data without any problem.

It would be great if csv() can also accept .tsv files

DQL

The following is one minimal example. Create two files named test.csv and test.tsv, both files containing the same following text:

header_1	header_2	header_3
a1	a2	a3
b1	b2	b3
c1	c2	c3

(In particular, test.csv will be a file with csv-extension but tsv data.) Put both files at the root folder of your vault.

Now create a note, also at the root folder of your vault, with the following code block inside.

```dataview
TABLE WITHOUT ID header_1, header_2, header_3
FROM csv("test.tsv")
```

This will render as an empty space ("Dataview: No results to show for table query."). But if you parse the csv-extension file instead,

```dataview
TABLE WITHOUT ID header_1, header_2, header_3
FROM csv("test.csv")
```

then the table shows up without any problem.

JS

Dataview Version

0.5.67

Obsidian Version

1.8.9

OS

Windows

@vivvienne vivvienne added the bug Something isn't working. label Mar 11, 2025
@holroy
Copy link
Collaborator

holroy commented Mar 11, 2025

There is a hard coded requirement that the csv file has to end with .csv in

return path.toLowerCase().endsWith(".csv");

Whether that is sensible, or not, that is another matter. I need to look a little more into that aspect of it, but for now you'll need to rename the file extension to .csv.

Is there any particular reason you're using .tsv?

@holroy holroy added documentation Improvements or additions to documentation DQL Query language UX, issues, and features. labels Mar 11, 2025
@vivvienne
Copy link
Author

vivvienne commented Mar 12, 2025

Thank you for the clarification about the hard coded check.

For me, it's not really a strict requirement I'm using the .tsv extension for tsv data files, but conceptually it's nicer to have file extensions align with their content. For example if I keep tsv data in a .csv file, other programs or plugins that handle .csv files very often start with assuming the data is in csv form (inferring from the extension), so it can become a chore having to correct the situation, especially in some cases where this cannot be done in a once and for all manner.

Seeing dataview can already parse tsv data, if the bottleneck (in my view) is only the extension restriction, it'd be really nice if it can accept .tsv extension files (with tsv data inside) too.

@holroy
Copy link
Collaborator

holroy commented Mar 12, 2025

Without promising to do this, it do seem to be an easy fix, but I also read somewhere that there are vital differences in how csv vs tsv handles escaping of text, and I can see that Dataview is doing some indexing on csv files which possibly need to be addressed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. documentation Improvements or additions to documentation DQL Query language UX, issues, and features.
Projects
None yet
Development

No branches or pull requests

2 participants