Open A-D-E-A opened 1 year ago
If we were to support this, I think we would use import attributes for options.
import * as csv from "./file.csv" with { headers: true };
why not CSV?
Is plan for bun (no pun) to add 1ā000ā000 features with no real standardisation? š
// once javascript was underrated and no one wanted to use it, now it seems the other way
Although it would be cool to be able to do something natively, bun to me seems to be a Javascript runtime. Not a syntactic sugar.
Any update please?
@A-D-E-A thanks. is your code recognizing the changes made to CSV and hot reload bun?
What is the problem this feature would solve?
I would like to import CSV data in my JS/TS code.
What is the feature you are proposing to solve the problem?
Since there are ways to import JSON, YAML and TOML, why not CSV?
I propose a plugin to import CSV files, either as a simple
string[][]
([["col1", "col2", "col3"], [...], ...]) or asRecord<string, string>[]
when using headers ([{col1: "data1", col2: "data2", col3: "data3"}, ...]).That plugin could do both by adding either an import attribute (though I don't think it's supported by the API yet) or a "query" after the file extension. Example:
The plugin is quite easy to code and doesn't need libraries. I could open a PR.
What alternatives have you considered?
Bun.file
.