Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikasoba/csv-parser
simple csv parser
https://github.com/ikasoba/csv-parser
Last synced: 15 days ago
JSON representation
simple csv parser
- Host: GitHub
- URL: https://github.com/ikasoba/csv-parser
- Owner: ikasoba
- Created: 2022-06-24T13:00:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-24T13:14:53.000Z (over 2 years ago)
- Last Synced: 2024-10-24T06:07:56.432Z (2 months ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# csv-parser
## how to install
### node
```sh
npm i https://github.com/ikasoba/csv-parser.git
```
### deno
```js
import {parser} from "https://raw.githubusercontent.com/ikasoba/csv-parser/main/src/index.ts"
```## how to parse csv
### parse simple csv file
```js
console.log(parser(`1,2,3,4
5,6,7,8`))
// [ [ "1", "2", "3", "4" ], [ "5", "6", "7", "8" ] ]
```### parse more value type
```js
console.log(parser(`1234,0xff,text,"""お前はもう、死んでいる"""`,raw => {
if (raw.match(/^\d+$/))return parseInt(raw);
else if (raw.match(/^0x[a-fA-F0-9]+$/))return parseInt(raw,16);
else return raw
}))
// [ [ 1234, 255, "text", '"お前はもう、死んでいる"' ] ]
```