Skip to content

peterthoeny/parse-csv-js

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

parseCsv (js)

Parse CSV/TSV data

This function parses CSV (comma-separated values) or TSV (tab-separated values) data, and returns a grid (array of arrays)

Table of contents

Usage

This function can be used in the browser, or in a Node.js environment. This example shows the latter.

const ParseCsv = require( "../parse-csv.js" );

const csv = 'A1,B1,C1\n"A ""2""","B, 2","C\n2"';
const separator = ',';      // field separator, default: ','
const newline = ' <br /> '; // newline representation in case a field contains newlines, default: '\n' 
var grid = ParseCsv.parseCsv(csv, separator, newline);
// expected: [ [ 'A1', 'B1', 'C1' ], [ 'A "2"', 'B, 2', 'C <br /> 2' ] ]

Dependencies

None.

About

Parse CSV/TSV data, and return a grid (array of arrays)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published