# parse-csv-to-obj

> Convert CSVs to Javascript objects.

Latest version **1.0.4** (published 2023-06-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install parse-csv-to-obj
pnpm add parse-csv-to-obj
yarn add parse-csv-to-obj
bun add parse-csv-to-obj
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2023-06-06 |
| First published | 2023-06-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Patrik Ackermann |
| Maintainers | patrikackermann |

## Links

- npm: https://www.npmjs.com/package/parse-csv-to-obj
- Repository: https://github.com/PatrikAckermann/csvparse
- Homepage: https://github.com/PatrikAckermann/csvparse#readme
- Issues: https://github.com/PatrikAckermann/csvparse/issues
- npm.io page: https://npm.io/package/parse-csv-to-obj

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## Recent versions

- 1.0.4 (latest) — 2023-06-06
- 1.0.3 — 2023-06-06
- 1.0.2 — 2023-06-05
- 1.0.1 — 2023-06-05
- 1.0.0 — 2023-06-05

## README

# CSVParse (parse-csv-to-obj on npm)

This package allows you to parse CSV files into JavaScript objects.

## Example

### Without any options

| 1 | 2 | 3 |
|---|---|---|
| 4 | 5 | 6 |
| 7 | 8 | 9 |

This converts to:

`[["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]]`

### With categories
This only has 1 column of categories. You can have an unlimited amount of nested categories.

| Category 1 | 1 | 2 | 3 |  |
|---|---|---|---|---|
|  | 4 | 5 | 6 |  |
| Category 2 | 7 | 8 | 9 |  |
|  |  |  |  |  |

This converts to:

`{"Category 1": [["1", "2", "3"], ["4", "5", "6"]], "Category 2": [["7", "8", "9"]]}`

## Quick start guide

### Installation
Run `npm install parse-csv-to-obj` in your projects directory.

### Inside your project
Enter `import csvparse from "parse-csv-to-obj"` at the beginning of your script.

Now use `csvparse(YourCsvString)` to parse the CSV.

## Option system
You can use options to alter the way the CSV is being read.

**Options**
- **integer**: Converts all number strings in the column to integers.
- - Valid values: All strings that only contain numbers are converted by this option.
- **boolean**: Converts all boolean strings in the column to integers.
- - Valid values: All strings that contain "0", "1", "false", "true", "f", or "t" are converted by this option.
- **category**: Creates a category in form of a nested object.
- - Valid usage: Only works on the first column or any column that's followed by a category column.

### How to use options
The 2nd argument for the csvparse() function is the option object. Use the column number (starting at 0) as the key and the option as the value.

Example: csvparse("1;2;3", {0: "category", 1: "integer"})

## Ignore lines
The 3rd argument for the csvparse() function is an array to define all lines that should be ignored.

Example: csvparse("1;2;3", {}, [0]) // This ignores the first row.

---
_Source: https://npm.io/package/parse-csv-to-obj · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
