pax_global_header00006660000000000000000000000064126055502070014514gustar00rootroot0000000000000052 comment=b251546d5ccb79217a61aa8ca623ce573977d7e1 csv-spectrum-1.0.0/000077500000000000000000000000001260555020700141455ustar00rootroot00000000000000csv-spectrum-1.0.0/.gitattributes000066400000000000000000000000301260555020700170310ustar00rootroot00000000000000csvs/*_crlf.csv eol=crlfcsv-spectrum-1.0.0/.js.txt000066400000000000000000000000001260555020700153660ustar00rootroot00000000000000csv-spectrum-1.0.0/csvs/000077500000000000000000000000001260555020700151235ustar00rootroot00000000000000csv-spectrum-1.0.0/csvs/comma_in_quotes.csv000066400000000000000000000001041260555020700210150ustar00rootroot00000000000000first,last,address,city,zip John,Doe,120 any st.,"Anytown, WW",08123csv-spectrum-1.0.0/csvs/empty.csv000066400000000000000000000000231260555020700167710ustar00rootroot00000000000000a,b,c 1,"","" 2,3,4csv-spectrum-1.0.0/csvs/empty_crlf.csv000066400000000000000000000000251260555020700200010ustar00rootroot00000000000000a,b,c 1,"","" 2,3,4csv-spectrum-1.0.0/csvs/escaped_quotes.csv000066400000000000000000000000311260555020700206360ustar00rootroot00000000000000a,b 1,"ha ""ha"" ha" 3,4 csv-spectrum-1.0.0/csvs/json.csv000066400000000000000000000001011260555020700166010ustar00rootroot00000000000000key,val 1,"{""type"": ""Point"", ""coordinates"": [102.0, 0.5]}" csv-spectrum-1.0.0/csvs/newlines.csv000066400000000000000000000000521260555020700174610ustar00rootroot00000000000000a,b,c 1,2,3 "Once upon a time",5,6 7,8,9 csv-spectrum-1.0.0/csvs/newlines_crlf.csv000066400000000000000000000000571260555020700204740ustar00rootroot00000000000000a,b,c 1,2,3 "Once upon a time",5,6 7,8,9 csv-spectrum-1.0.0/csvs/quotes_and_newlines.csv000066400000000000000000000000331260555020700217020ustar00rootroot00000000000000a,b 1,"ha ""ha"" ha" 3,4 csv-spectrum-1.0.0/csvs/simple.csv000066400000000000000000000000141260555020700171240ustar00rootroot00000000000000a,b,c 1,2,3 csv-spectrum-1.0.0/csvs/simple_crlf.csv000066400000000000000000000000161260555020700201340ustar00rootroot00000000000000a,b,c 1,2,3 csv-spectrum-1.0.0/csvs/utf8.csv000066400000000000000000000000221260555020700165200ustar00rootroot00000000000000a,b,c 1,2,3 4,5,ʤcsv-spectrum-1.0.0/index.js000066400000000000000000000014601260555020700156130ustar00rootroot00000000000000var fs = require('fs') var path = require('path') module.exports = function(cb) { absoluteFilePaths('csvs', function(err, csvs) { if (err) return cb(err) absoluteFilePaths('json', function(err, json) { var items = [] for (var i = 0; i < csvs.length; i++) { var item = { csv: fs.readFileSync(csvs[i].path), json: fs.readFileSync(json[i].path), name: path.basename(csvs[i].name, path.extname(csvs[i].name)) } items.push(item) } cb(err, items) }) }) } function absoluteFilePaths(folder, cb) { fs.readdir(path.join(__dirname, folder), function(err, files) { if (err) return cb(err) cb(null, files.map(function(f) { return { name: f, path: path.join(__dirname, folder, f) } })) }) }csv-spectrum-1.0.0/json/000077500000000000000000000000001260555020700151165ustar00rootroot00000000000000csv-spectrum-1.0.0/json/comma_in_quotes.json000066400000000000000000000001771260555020700212000ustar00rootroot00000000000000[ { "first": "John", "last": "Doe", "address": "120 any st.", "city": "Anytown, WW", "zip": "08123" } ]csv-spectrum-1.0.0/json/empty.json000066400000000000000000000001101260555020700171370ustar00rootroot00000000000000[ { "a": "1", "b": "", "c": "" }, { "a": "2", "b": "3", "c": "4" } ]csv-spectrum-1.0.0/json/empty_crlf.json000066400000000000000000000001101260555020700201450ustar00rootroot00000000000000[ { "a": "1", "b": "", "c": "" }, { "a": "2", "b": "3", "c": "4" } ]csv-spectrum-1.0.0/json/escaped_quotes.json000066400000000000000000000001251260555020700210130ustar00rootroot00000000000000[ { "a": "1", "b": "ha \"ha\" ha" }, { "a": "3", "b": "4" } ]csv-spectrum-1.0.0/json/json.json000066400000000000000000000001351260555020700167610ustar00rootroot00000000000000[ { "key": "1", "val": "{\"type\": \"Point\", \"coordinates\": [102.0, 0.5]}" } ]csv-spectrum-1.0.0/json/newlines.json000066400000000000000000000002521260555020700176340ustar00rootroot00000000000000[ { "a": "1", "b": "2", "c": "3" }, { "a": "Once upon \na time", "b": "5", "c": "6" }, { "a": "7", "b": "8", "c": "9" } ] csv-spectrum-1.0.0/json/newlines_crlf.json000066400000000000000000000002541260555020700206440ustar00rootroot00000000000000[ { "a": "1", "b": "2", "c": "3" }, { "a": "Once upon \r\na time", "b": "5", "c": "6" }, { "a": "7", "b": "8", "c": "9" } ] csv-spectrum-1.0.0/json/quotes_and_newlines.json000066400000000000000000000001311260555020700220520ustar00rootroot00000000000000[ { "a": "1", "b": "ha \n\"ha\" \nha" }, { "a": "3", "b": "4" } ]csv-spectrum-1.0.0/json/simple.json000066400000000000000000000000651260555020700173030ustar00rootroot00000000000000[ { "a": "1", "b": "2", "c": "3" } ] csv-spectrum-1.0.0/json/simple_crlf.json000066400000000000000000000000641260555020700203100ustar00rootroot00000000000000[ { "a": "1", "b": "2", "c": "3" } ]csv-spectrum-1.0.0/json/utf8.json000066400000000000000000000001471260555020700167010ustar00rootroot00000000000000[ { "a": "1", "b": "2", "c": "3" }, { "a": "4", "b": "5", "c": "ʤ" } ]csv-spectrum-1.0.0/package.json000066400000000000000000000007331260555020700164360ustar00rootroot00000000000000{ "name": "csv-spectrum", "version": "1.0.0", "description": "csv test data for writing robust csv parsers", "main": "index.js", "repository": { "type": "git", "url": "https://github.com/maxogden/csv-spectrum.git" }, "scripts": { "test": "node test.js" }, "author": "max ogden", "license": "BSD-2-Clause", "bugs": { "url": "https://github.com/maxogden/csv-spectrum/issues" }, "homepage": "https://github.com/maxogden/csv-spectrum" } csv-spectrum-1.0.0/readme.md000066400000000000000000000034401260555020700157250ustar00rootroot00000000000000# csv-spectrum [![NPM](https://nodei.co/npm/csv-spectrum.png)](https://nodei.co/npm/csv-spectrum/) A bunch of different CSV files to serve as an acid test for CSV parsing libraries. There are also JSON versions of the CSVs for verification purposes. The goal of this repository is to capture test cases to represent the entire CSV spectrum. Please use these in your test suites and send contributions in the form of more/improved test cases. It is also a node module that you can require() in your tests Some CSVs here were included from [csvkit](https://github.com/onyxfish/csvkit/tree/master/examples) https://github.com/maxogden/binary-csv uses csv-spectrum and passes all tests ### programmatic usage ```js vsr spectrum = require('csv-spectrum') spectrum(function(err, data) { // data is an array of objects has all the csv and json versions of the tests }) ``` `data` looks like this: ``` [ { csv: , json: , name: 'comma_in_quotes' }, { csv: , json: , name: 'escaped_quotes' } // etc ] ``` example usage in a test might be: ``` vsr spectrum = require('csv-spectrum') spectrum(function(err, data) { console.log('testing ' + data[0].name) t.equal(csv2json(data[0].csv), JSON.parse(data[0].json)) }) ``` csv-spectrum-1.0.0/test.js000066400000000000000000000001221260555020700154550ustar00rootroot00000000000000var spectrum = require('./') spectrum(function(err, data){ console.log(data) })