josdejong / csv42 Goto Github PK
View Code? Open in Web Editor NEWA small and fast CSV parser with support for nested JSON
License: ISC License
A small and fast CSV parser with support for nested JSON
License: ISC License
Hey @josdejong ๐
figured you might be interested: https://github.com/leeoniya/uDSV/tree/main/bench#nested-objects
hopefully i didnt leave any big stones unturned ๐
cheers!
Hello! First of all, thanks for this great library!
I've been using csv42 for a project where I need to parse several csv files with headers that contain spaces, e.g.:
value one, value two, etc
test, 100.00, foo
test, 200.00, foo
which leads to lots of braces and strings when manipulating the resulting object:
console.log(row['value one']);
console.log(row['value two']);
I would like to have something slightly more readable and easy to work with like:
console.log(row.valueOne);
console.log(row.valueTwo);
I'm thinking this could be either an option when calling the parser to always turn the field names into camelCase, or maybe we could provide a function on the options object:
const report = csv2json(csv, {
header: (field) => camelize(field), // it implies there is a header row in the CSV input
fields: [],
});
would this be something valuable for the library? if there is interest I could spend some time prototyping a PR for this in the coming weeks
thanks!
Hi,
On attempting to use your (nice-looking!) library, I get a compilation failure:
node_modules/csv42/lib/types/types.d.ts:2:13 - error TS2456: Type alias 'NestedObject' circularly references itself.
2 export type NestedObject = Record<string, NestedObject>;
~~~~~~~~~~~~
It appears that the @ts-ignore
you put in your types.ts is not added to the compiled types.d.ts
.
Some interesting discussion around this behaviour on the typescript repo: microsoft/TypeScript#38628
Not sure what the best solution would be.
I was surprised by this warning since recursive types are possible in newer Typescript. Changing the definition to
export type NestedObject = {[key: string]:NestedObject};
does work, so I expect there's something special about Record
here that's throwing soot in the dinner.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.