New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

simplecsv

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplecsv

Fast and compact CSV parser for parsing CSV with CSV to JSON support.

  • 0.0.49
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28
decreased by-37.78%
Maintainers
1
Weekly downloads
 
Created
Source

SimpleCSV.js Logo

SimpleCSV.js is a fast and compact JavaScript CSV library for parsing csv strings, and parsing JSON table objects.

Features

  • In-the-Browser, For-The-Browser: Only 3 lines of code to parse CSV strings, and JSON tables.
  • Python csv compatible: Guaranteed to produce the same results as Python 2.7 csv parser.
  • JSON parser: Convert CSV to JSON, or JSON to CSV.
  • No dependancies: Tiny standalone .js file.

Downloads

Examples

Browser

In any web page:

<script src="http://simplecsvjs.com/dist/simplecsv.0.0.47.standalone.min.js"></script>
<script>
  var simplecsv = require('simplecsv');
  var csv = new simplecsv.csv();

  var parsedCsvdata = csv.parseString('Turing, 35, chess\nSamuel, 21, checkers');
</script>

Node.js

var simplecsv = require('simplecsv');
var csv = new simplecsv.csv();

var parsedCsvdata = csv.parseString('Turing, 35, chess\nSamuel, 21, checkers');

More Examples

CSV to JSON

var simplecsv = require('simplecsv');
var csv = new simplecsv.csv();

var jsonObj = csv.CSVToJSON('Planet Name, Color\nMars,red-orange\nUranus,light-blue',
                            { hasHeaders: true });
console.log(jsonObj);

output is:

[{"Planet Name":"Mars"," Color":"red-orange"},{"Planet Name":"Uranus"," Color":"light-blue"}]

JSON -> CSV

var simplecsv = require('simplecsv');
var csv = new simplecsv.csv();

var str  = csv.JSONToCSV('[{"Planet Name":"Mars"," Color":"red-orange"},' +
                         '{"Planet Name":"Uranus"," Color":"light-blue"}]');
console.log(str);

output is:

Planet Name, Color
Mars,red-orange
Uranus,light-blue

console.log() every cell

var simplecsv = require('simplecsv');
var csv = new simplecsv.csv();

var cdata = csv.parseString('Planet Name, Color\nMars,red-orange\nUranus,light-blue', { hasHeaders: true });
for (var i = 0; i < cdata.rowCount; i++) {
  for (var j = 0; j < cdata.columnCount; j++) {
    console.log(cdata.rows[i][j]);
  }
}

find errors

var simplecsv = require('simplecsv');
var csv = new simplecsv.csv();

var cdata = csv.parseString('Planet Name, Color\nMars\nred-orange, Uranus,light-blue', { hasHeaders: true });
console.log(csv.findErrors(cdata));

Quick Start

Install

Install with npm.

$ npm install simplecsv

Newline

SimpleCSV.js uses \n and \r\n for newline when parsing. Currently there is no support for Mac's \r for newline (i.e. universal mode in Python csv).

Support

For bug reports, feature requests and general questions, please feel free to email baris@onehundredyearsofcode.com.

Development

Refer to development notes

Documentation

Library manual

Keywords

FAQs

Package last updated on 17 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc