# createcsvfrom

> Create CSV files from various sources via CLI

Latest version **1.1.0** (published 2022-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install createcsvfrom
pnpm add createcsvfrom
yarn add createcsvfrom
bun add createcsvfrom
```

Provides the command `createcsvfrom`.

## 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.1.0 |
| Published | 2022-08-10 |
| First published | 2022-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^14.19.0 |
| Dependencies | 7 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kai Kappel |
| Maintainers | kappxl |
| Keywords | mongodb, csv, convert, json, cli, postgres |

## Links

- npm: https://www.npmjs.com/package/createcsvfrom
- npm.io page: https://npm.io/package/createcsvfrom

## Dependencies (7)

- [pg](https://npm.io/package/pg.md) ^8.7.3
- [chalk](https://npm.io/package/chalk.md) 4
- [mongodb](https://npm.io/package/mongodb.md) ^4.8.1
- [commander](https://npm.io/package/commander.md) ^9.4.0
- [pg-cursor](https://npm.io/package/pg-cursor.md) ^2.7.3
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [cli-progress](https://npm.io/package/cli-progress.md) ^3.11.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-08-10
- 1.0.2 — 2022-08-10
- 1.0.1 — 2022-08-10
- 1.0.0 — 2022-08-09

## README

# CLI CSV Converter

Creates CSV files from various sources via CLI

## Installation

```
npm i -g createcsvfrom
```

## Functions

### MongoDB Collection to CSV

Converts a MongoDB collection directly into a CSV file.

**Usage**

```bash
convertCSV mongodb [options]
```

**Options**

```bash
-u, --uri <uri>                MongoDB uri.
-d, --db <db>                  MongoDB database.
-c, --collection <collection>  MongoDB collection.
-o, --out <out>                OPTIONAL. The CSV result file. Default: result.csv
-q, --query <query>            OPTIONAL. MongoDB query.
-h, --help                     display help for command
```

**Example**

```bash
convertCSV mongodb -u '<mongodb_uri>' -o output.csv -d my_database -c my_collection -q '{"country": "DE"}'
```

**MongoDB uri example:**

```
mongodb://<my_user>:<my_pw>@<my_host>:<my_port>/<my_default_auth_db>?replicaSet=<my_replica_set>
```

### JSON file to CSV

Converts a JSON file to a CSV file.
One JSON object per line.

**Usage**

```bash
convertCSV json [options]
```

**Options**

```bash
-f, --file <file>  The JSON file to convert to CSV.
-o, --out <out>    OPTIONAL. The CSV result file. Default: result.csv
-h, --help         display help for command
```

**Example**

```bash
convertCSV json -f '/path/to/json/file.json' -o result.csv
```

### Postgres to CSV

Converts a Postgres table to a CSV file.

**Usage**

```bash
createcsvfrom pg [options]
```

**Options**

```bash
--uri <uri>      Postgres connection uri.
--host <host>    Postgres host.
--port <port>    Postgres port.
--user <user>    Postgres user.
--pw <password>  Postgres password.
--db <database>  Postgres database.
--query <query>  Postgres query to convert.
-o, --out <out>  OPTIONAL. The CSV result file. Default: result.csv
-h, --help       display help for command
```

**Example**

```bash
createcsvfrom pg --uri postgresql://<user>:<password>@<host>:<port>/<database> --query 'SELECT * from books limit 5000;' -o ~HOME/output.csv
```

```bash
createcsvfrom pg --host <my_host> --user <my_user> --pw <my_pw> --port <my_port> --db <my_db> --query 'SELECT * from books limit 5000;'
```

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