blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
6.86k stars 406 forks source link

CSV parsing fault #1750

Open YannisCS50 opened 1 year ago

YannisCS50 commented 1 year ago

What happened?

When parsing a .csv file, every row in the first column has null value and is marked with - (as it is set in the settings). It happens in every .csv file that I have tried, in both cases of using DQL or JS.

Sample csv file: Book1.csv

Result:

image

Workaround: (applied/work only when using JS) (credit to Discord user @River)

It works if this line would be changed with

dv.table(headers , data.map(x=> [x.eventdate, x.eventName]))

this line

dv.table(headers , data.map(x=> [x["-eventdate"], x.eventName]))

DQL

TABLE WITHOUT ID eventDate, eventName 
FROM csv("attachments/book1.csv") 

JS

const data = await dv.io.csv("attachments/book1.csv") 
const headers = ["eventDate","eventName"]
dv.table(headers , data.map(x=> [x.eventdate, x.eventName]))

Workaround:

const data = await dv.io.csv("attachments/book1.csv") 
const headers = ["eventDate","eventName"]
dv.table(headers , data.map(x=> [x["-eventdate"], x.eventName]))

Dataview Version

0.5.52

Obsidian Version

1.1.9

OS

MacOS

r-tae commented 1 year ago

From my brief investigation, it looked like the first column of the CSV was prepended with a zero-width space character. There was no ZWS in the csv file, so I believe DV added it.

This explains the normalised name beginning with -, but I didn't figure out the root cause.

AB1908 commented 1 year ago

Thanks for the report. This is certainly one of the more detailed ones haha. ❤️