I have a large csv file in the following format containing different sensor outputs per timestamp.
The header looks like this:
timestamp;DeviationID ValueY;CuStepNo ValueY;LevelMainTank ValueY;YC10001_MV ValueY;[…]
And values look like this:
2018-10-10 14:53:19;1;1;149.985778808594;100;
So everything is either int or float, except for the timestamp column.
I now want to read this csv file and plot it with lilaq, using the timestamp column as my y-Axis.
I believe I need lq.load-txt with a converters dict, but I haven’t been able to get it to work correctly.
Could you please provide an example of the code you have been trying, that in order for us to help you faster? Something we can copy/paste or a link to a typst.app project?
Sure, here’s a subset from the first 200 lines (it includes more columns than the example I posted above).
Link (since new users can’t upload directly on here): 82.4 KB file on MEGA
#let data = lq.load-txt(read("./data/SmA-Four-Tank-Batch-Process_V2.csv"), header: true, delimiter: ";", converters: (
"DeviationID": datetime, //Change this to the real name of column 1
"rest": float,
))
Hmmmm… the subset I uploaded seems to be missing the first column named “timestamp” from the header…
But this then wouldn’t change my code where I already use “timestamp” for the column name.
JSON data is typed, i.e., there are strings, ints, floats, arrays, and objects (dictionaries) and the Typst function json automatically converts these types to Typst types (unlike with CSV).
Thanks for the code! I’ll have to take a closer look at this. I just noticed when viewing my csv in in hex editor that I have some weird bytes just before timestamp in my header…