UNPKG

@exodus/papaparse

Version:

Fast and powerful CSV parser for the browser that supports web workers and streaming large files. Converts CSV to JSON and JSON to CSV.

40 lines (35 loc) 673 B
const papaparse = require("./papaparse") const data = [ { "Column 1": "1-1", "Column 2": "1-2", "Column 3": "1-3", "Column 4": "1-4" }, { "Column 1": "2-1", "Column 2": "2-2", "Column 3": "2-3", "Column 4": "2-4" }, { "Column 1": "3-1", "Column 2": "3-2", "Column 3": "3-3", "Column 4": "3-4" }, { "Column 1": 4, "Column 2": 5, "Column 3": 6, "Column 4": 7 } ] const csv = `Column 1,Column 2,Column 3,Column 4 1-1,1-2,1-3,1-4 2-1,2-2,2-3,2-4 3-1,3-2,3-3,3-4 4,5,6,7` const csvRows = papaparse.unparse(data, { header: false }) console.log(csvRows) console.log(papaparse.parse(csv))