Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: adaltas/node-csv
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: csv@5.5.3
Choose a base ref
...
head repository: adaltas/node-csv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: csv@6.0.0
Choose a head ref

Commits on Sep 17, 2021

  1. feat: esm migration

    wdavidw committed Sep 17, 2021
    Copy the full SHA
    b5c0d4b View commit details
  2. Copy the full SHA
    6e75460 View commit details

Commits on Oct 2, 2021

  1. Copy the full SHA
    5888f76 View commit details

Commits on Oct 8, 2021

  1. Copy the full SHA
    5438894 View commit details

Commits on Oct 12, 2021

  1. test: fix sample scheduling

    wdavidw committed Oct 12, 2021
    Copy the full SHA
    c654821 View commit details
  2. Copy the full SHA
    9e01865 View commit details

Commits on Oct 13, 2021

  1. Copy the full SHA
    b8f6457 View commit details
  2. Copy the full SHA
    879a9dd View commit details
  3. Copy the full SHA
    177e2ce View commit details
  4. build: apply lint rules

    build: apply 2
    wdavidw committed Oct 13, 2021
    Copy the full SHA
    eb841c3 View commit details
  5. Copy the full SHA
    3decdf1 View commit details
  6. chore: upgrade dependencies

    wdavidw committed Oct 13, 2021
    Copy the full SHA
    0eb9b50 View commit details
  7. Copy the full SHA
    e3a57fe View commit details
  8. build: support coffeelint

    wdavidw committed Oct 13, 2021
    Copy the full SHA
    49d64fe View commit details
  9. Copy the full SHA
    83134d2 View commit details
  10. Copy the full SHA
    ddde5de View commit details

Commits on Oct 15, 2021

  1. refactor: lint samples

    wdavidw committed Oct 15, 2021
    Copy the full SHA
    2e4a1fd View commit details
  2. Copy the full SHA
    b7ff425 View commit details

Commits on Oct 18, 2021

  1. Copy the full SHA
    710ef7b View commit details
  2. docs: comment stream samples

    wdavidw committed Oct 18, 2021
    Copy the full SHA
    d188c9f View commit details
  3. Copy the full SHA
    acb41d5 View commit details
  4. Copy the full SHA
    a5b4cf5 View commit details
  5. Copy the full SHA
    2c2623f View commit details

Commits on Oct 21, 2021

  1. Copy the full SHA
    2741990 View commit details

Commits on Oct 22, 2021

  1. Copy the full SHA
    b756bd6 View commit details
  2. docs: issue 298 sample

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    f7313bd View commit details
  3. feat: export ts types in sync

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    890bf8d View commit details
  4. docs: package.json issues

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    c169b17 View commit details
  5. build: missing files

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    44a3b37 View commit details
  6. docs: esm demo

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    e26fd26 View commit details
  7. docs: cjs demo

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    66006cf View commit details
  8. build: lint all packages

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    c804dbf View commit details
  9. Copy the full SHA
    b780fbd View commit details
  10. docs: use ts-node in cjs demo

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    a75daa9 View commit details
  11. Copy the full SHA
    dbfeb78 View commit details
  12. docs: lint demo

    wdavidw committed Oct 22, 2021
    Copy the full SHA
    aa26752 View commit details

Commits on Oct 25, 2021

  1. Copy the full SHA
    496231d View commit details
  2. Copy the full SHA
    24f867a View commit details
  3. Copy the full SHA
    be25349 View commit details
  4. Copy the full SHA
    a13c558 View commit details
  5. Copy the full SHA
    fc89380 View commit details
  6. build: add node 8 sync files

    wdavidw committed Oct 25, 2021
    Copy the full SHA
    df835c5 View commit details

Commits on Oct 26, 2021

  1. chore: export lib

    wdavidw committed Oct 26, 2021
    Copy the full SHA
    8897366 View commit details
  2. test(csv): export parse error

    wdavidw committed Oct 26, 2021
    Copy the full SHA
    7452431 View commit details
  3. docs: issue 298 file 2

    wdavidw committed Oct 26, 2021
    Copy the full SHA
    3f88312 View commit details
  4. Copy the full SHA
    13bb782 View commit details
  5. Copy the full SHA
    b5f51db View commit details
  6. Copy the full SHA
    691c73b View commit details
  7. Copy the full SHA
    089ae5f View commit details
  8. Copy the full SHA
    7615d78 View commit details
Showing 469 changed files with 247,042 additions and 96,179 deletions.
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
@@ -13,7 +12,9 @@ A clear and concise description of what the bug is, the CSV package version you

**To Reproduce**

Please provide us with a unit test, an example code or even pseudo-code. It could be written in JavaScript or CoffeeScript, it doesn't matter. What's important is to limit the data to the minimum as well as to strip down the number of options to the only ones with an impact.
Please provide us with a unit test, an example code or even pseudo-code. It could be written in JavaScript or CoffeeScript, but not in TypeScript unless the bug is related to TypeScript.

What's important is to **limit the data** to the minimum as well as to **strip down the number of options** to the relevant ones with an impact. Do not reference an external file.

**Additional context**

5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: CSV Documentation
url: https://csv.js.org/
about: Check out the CSV documentation for answers to common questions
17 changes: 10 additions & 7 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -4,20 +4,23 @@ about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
**Summary**

A clear and concise description of what the feature is.

**Motivation**

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
If the feature is related to a problem, describe it. Add any other context explaining why this feature is of interest to you and the community.

**Describe the solution you'd like**
**Alternative**

A clear and concise description of what you want to happen.
A clear and concise description of alternative solutions or features you've considered.

**Describe alternatives you've considered**
**Draft**

A clear and concise description of any alternative solutions or features you've considered.
Write a proposal for the feature, how it works, its expected coverage, a sample code or unit test. If the feature is related to a documentation or article, write the content or the table of content you expect.

**Additional context**

52 changes: 52 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: yarn run test
test_legacy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: yarn run test:legacy
publish:
needs: [test, test_legacy]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- run: yarn --frozen-lockfile
- run: yarn run publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.*
/node_modules
/packages/*/node_modules
node_modules
!.eslintrc
!.github
!.gitignore
!.husky
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@

</pre>

# CSV packages for Node.js and the web

This project provides CSV generation, parsing, transformation and serialization for Node.js.

It has been tested and used by a large community over the years and should be considered reliable. It provides every option you would expect from an advanced CSV parser and stringifier.
@@ -17,21 +19,47 @@ It has been tested and used by a large community over the years and should be co

This repository is a monorepo managed using [Lerna](https://github.com/lerna/lerna). There are 5 packages managed in this codebase, even though we publish them to NPM as separate packages:

* [`csv`](packages/csv/),
an umbrella which is itself split into 4 packages.
* [`csv-generate`](packages/csv-generate/),
a flexible generator of CSV string and Javascript objects.
* [`csv-parse`](packages/csv-parse/),
a parser converting CSV text into arrays or objects.
* [`csv-stringify`](packages/csv-stringify/),
a stringifier converting records into a CSV text.
* [`stream-transform`](packages/stream-transform/),
a transformation framework.
* [`csv`](https://csv.js.org/)
([GitHub](https://github.com/adaltas/node-csv/tree/master/packages/csv)),
an umbrella which is itself split into 4 packages.
* [`csv-generate`](https://csv.js.org/generate/)
([GitHub](https://github.com/adaltas/node-csv/tree/master/packages/csv-generate)),
a flexible generator of CSV string and Javascript objects.
* [`csv-parse`](https://csv.js.org/parse/)
([GitHub](https://github.com/adaltas/node-csv/tree/master/packages/csv-parse)),
a parser converting CSV text into arrays or objects.
* [`csv-stringify`](https://csv.js.org/stringify/)
([GitHub](https://github.com/adaltas/node-csv/tree/master/packages/csv-stringify)),
a stringifier converting records into a CSV text.
* [`stream-transform`](https://csv.js.org/transform/)
([GitHub](https://github.com/adaltas/node-csv/tree/master/packages/stream-transform)),
a transformation framework.

## Documentation

The full documentation for the current version is available [here](https://csv.js.org).

* [Getting Started](https://csv.js.org/project/getting-started/)
* [Examples](https://csv.js.org/project/examples/)
* [License](https://csv.js.org/project/license/)
* [Community](https://csv.js.org/project/contribute/)

## Features

* Extends the native Node.js [transform stream API](http://nodejs.org/api/stream.html#stream_class_stream_transform)
* Simplicity with the optional callback and sync API
* Support for ECMAScript modules and CommonJS
* Large documentation, numerous examples and full unit test coverage
* Few dependencies, in many cases zero dependencies
* Node.js support from version 8 to latest
* Mature project with more than 10 years of history

## License

Licensed under the [MIT License](LICENSE).

## Contributors

The project is sponsored by [Adaltas](https://www.adaltas.com), an Big Data consulting firm based in Paris, France.

* David Worms: <https://github.com/wdavidw>
97 changes: 97 additions & 0 deletions demo/browser/esm/csv.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<!DOCTYPE html>
<html>
<head>
<title>CSV parse demo</title>
<style>
div {
width: 60%;
margin: 5rem auto;
text-align: center;
}
textarea {
width: 100%;
height: 200px;
}
input {
margin: 1rem;
}
pre {
text-align: left;
padding: 2rem;
border: 1px solid black;
}
</style>
</head>
<body>
<div>
<h1>CSV demo</h1>
<p><a href="/">back</a></p>
<label for="generateOptions">Generate options:</label>
<textarea id="generateOptions"></textarea>
<label for="parseOptions">Parse options:</label>
<textarea id="parseOptions"></textarea>
<label for="transformOptions">Transform handler:</label>
<textarea id="transformOptions"></textarea>
<label for="stringifyOptions">Stringify options:</label>
<textarea id="stringifyOptions"></textarea>
<input id="run" type="submit" value="run" />
<pre><code id="output"></code></pre>
<script type="module">
import * as csv from '/lib/esm/csv/sync.js';
const runEl = document.getElementById('run');
const generateOptionsEl = document.getElementById('generateOptions');
generateOptionsEl.innerHTML = JSON.stringify({
delimiter: '|',
length: 10
}, null, 2);
const parseOptionsEl = document.getElementById('parseOptions');
parseOptionsEl.innerHTML = JSON.stringify({
delimiter: '|'
}, null, 2);
const transformOptionsEl = document.getElementById('transformOptions');
transformOptionsEl.innerHTML = [
'function(record){',
' return record;',
'}'
].join('\n');
const stringifyOptionsEl = document.getElementById('stringifyOptions');
stringifyOptionsEl.innerHTML = JSON.stringify({
quoted: true
}, null, 2);
const outputEl = document.getElementById('output');
runEl.onclick = (e) => {
try{
const generateOptions = JSON.parse(generateOptionsEl.value);
const parseOptions = JSON.parse(parseOptionsEl.value);
const transform = {};
eval(`transform.handler = ${transformOptionsEl.value}`);
const stringifyOptions = JSON.parse(stringifyOptionsEl.value);
// Run the pipeline
csv
// Generate 20 records
.generate(generateOptions)
// Transform CSV data into records
.pipe(csv.parse({
delimiter: '|'
}))
// Transform each value into uppercase
.pipe(csv.transform(transform.handler))
// Convert objects into a stream
.pipe(csv.stringify(stringifyOptions))
// Print the CSV stream to stdout
.on('readable', function () {
let chunck; while(chunck = this.read()){
outputEl.innerHTML = outputEl.innerHTML + chunck.toString()
}
})
.on('error', function (err) {
outputEl.innerHTML = 'Error: ' + err.message;
});
}catch(err){
outputEl.innerHTML = 'Error: ' + err.message;
}
};
</script>
</div>
</body>
</html>
82 changes: 82 additions & 0 deletions demo/browser/esm/csv_sync.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>
<head>
<title>CSV parse demo</title>
<style>
div {
width: 60%;
margin: 5rem auto;
text-align: center;
}
textarea {
width: 100%;
height: 200px;
}
input {
margin: 1rem;
}
pre {
text-align: left;
padding: 2rem;
border: 1px solid black;
}
</style>
</head>
<body>
<div>
<h1>CSV demo</h1>
<p><a href="/">back</a></p>
<label for="generateOptions">Generate options:</label>
<textarea id="generateOptions"></textarea>
<label for="parseOptions">Parse options:</label>
<textarea id="parseOptions"></textarea>
<label for="transformOptions">Transform handler:</label>
<textarea id="transformOptions"></textarea>
<label for="stringifyOptions">Stringify options:</label>
<textarea id="stringifyOptions"></textarea>
<input id="run" type="submit" value="run" />
<pre><code id="output"></code></pre>
<script type="module">
import * as csv from '/lib/esm/csv/sync.js';
const runEl = document.getElementById('run');
const generateOptionsEl = document.getElementById('generateOptions');
generateOptionsEl.innerHTML = JSON.stringify({
delimiter: '|',
length: 10
}, null, 2);
const parseOptionsEl = document.getElementById('parseOptions');
parseOptionsEl.innerHTML = JSON.stringify({
delimiter: '|'
}, null, 2);
const transformOptionsEl = document.getElementById('transformOptions');
transformOptionsEl.innerHTML = [
'function(record){',
' return record;',
'}'
].join('\n');
const stringifyOptionsEl = document.getElementById('stringifyOptions');
stringifyOptionsEl.innerHTML = JSON.stringify({
quoted: true
}, null, 2);
const outputEl = document.getElementById('output');
runEl.onclick = (e) => {
try{
const generateOptions = JSON.parse(generateOptionsEl.value);
const parseOptions = JSON.parse(parseOptionsEl.value);
const transform = {};
eval(`transform.handler = ${transformOptionsEl.value}`);
const stringifyOptions = JSON.parse(stringifyOptionsEl.value);
// Run the pipeline
const input = csv.generate(generateOptions);
const rawRecords = csv.parse(input, parseOptions);
const refinedRecords = csv.transform(rawRecords, transform.handler);
const output = csv.stringify(refinedRecords, stringifyOptions);
outputEl.innerHTML = output;
}catch(err){
outputEl.innerHTML = 'Error: ' + err.message;
}
};
</script>
</div>
</body>
</html>
Loading