nickpisacane / Csvbuilder
Licence: mit
Easily encode complex JSON objects to CSV with CsvBuilder's schema-like API
Stars: ✭ 128
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Csvbuilder
Csv Stream
📃 Streaming CSV Parser for Node. Small and made entirely out of streams.
Stars: ✭ 98 (-23.44%)
Mutual labels: stream, csv
tabular-stream
Detects tabular data (spreadsheets, dsv or json, 20+ different formats) and emits normalized objects.
Stars: ✭ 34 (-73.44%)
Mutual labels: csv, stream
eec
A fast and lower memory excel write/read tool.一个非POI底层,支持流式处理的高效且超低内存的Excel读写工具
Stars: ✭ 93 (-27.34%)
Mutual labels: csv, stream
text2json
Performant parser for textual data (CSV parser)
Stars: ✭ 33 (-74.22%)
Mutual labels: csv, stream
pcap-processor
Read and process pcap files using this nifty tool
Stars: ✭ 36 (-71.87%)
Mutual labels: csv, stream
Iostreams
IOStreams is an incredibly powerful streaming library that makes changes to file formats, compression, encryption, or storage mechanism transparent to the application.
Stars: ✭ 84 (-34.37%)
Mutual labels: stream, csv
React Papaparse
react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
Stars: ✭ 116 (-9.37%)
Mutual labels: stream, csv
Import
This is a library that provides generic functionalities for the implementation of imports. In addition to maximum performance and optimized memory consumption, Pacemaker can also be used to implement imports in distributed scenarios that place the highest demands on speed and stability.
Stars: ✭ 125 (-2.34%)
Mutual labels: csv
Django Crud Ajax Login Register Fileupload
Django Crud, Django Crud Application, Django ajax CRUD,Django Boilerplate application, Django Register, Django Login,Django fileupload, CRUD, Bootstrap, AJAX, sample App
Stars: ✭ 118 (-7.81%)
Mutual labels: csv
30 Days Of Python
Learn Python for the next 30 (or so) Days.
Stars: ✭ 1,748 (+1265.63%)
Mutual labels: csv
Rightmove webscraper.py
Python class to scrape data from rightmove.co.uk and return listings in a pandas DataFrame object
Stars: ✭ 125 (-2.34%)
Mutual labels: csv
Rbql
🦜RBQL - Rainbow Query Language: SQL-like language for (not only) CSV file processing. Supports SQL queries with Python and JavaScript expressions
Stars: ✭ 118 (-7.81%)
Mutual labels: csv
Winmerge
WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
Stars: ✭ 2,358 (+1742.19%)
Mutual labels: csv
Csv Diff
Python CLI tool and library for diffing CSV and JSON files
Stars: ✭ 118 (-7.81%)
Mutual labels: csv
England
Football data for England (and Wales) incl. English Premier League, The Football League (Championship, League One, League Two), Football Conference etc.
Stars: ✭ 117 (-8.59%)
Mutual labels: csv
Couchimport
CouchDB import tool to allow data to be bulk inserted
Stars: ✭ 125 (-2.34%)
Mutual labels: csv
Csvbuilder
Easily encode complex JSON objects to CSV with CsvBuilder's schema-like API.
Table Of Contents
Usage
const CsvBuilder = require('csv-builder')
const data = [
{
name: 'Foo Bar',
meta: {
active: true,
roles: [
'user',
'admin'
]
}
}
]
const builder = new CsvBuilder({
headers: ['Firstname', 'Lastname', 'Role 1', 'Role 2', 'Active'],
alias: {
'Role 1': 'meta.roles[0]',
'Role 2': 'meta.roles[1]',
'Active': 'meta.active'
}
})
.virtual('Firstname', user => user.name.split(' ')[0])
.virtual('Lastname', user => user.name.split(' ')[1])
/* Each of the following produces the following CSV contents:
"Firstname","Lastname","Role 1","Role 2","Active"
"Foo","Bar","user","admin","true"
*/
// (1) Create from a Stream of objects (like a database)
getObjectStream()
.pipe(builder.createTransformStream())
.pipe(fs.createWriteStream('output.csv'))
// (2) Create from an existing payload (`data` is an array of objects)
builder.createReadStream(data)
.pipe(fs.createWriteStream('output.csv'))
// (3) Roll your own
let csv = ''
csv += builder.getHeaders()
data.forEach(item => {
csv += builder.getRow(item)
})
fs.writeFileSync('output.csv', csv)
Installation
$ npm i -s csv-builder
# or
$ yarn add csv-builder
New Features
- More cohesive API
- Expanded API to support non-stream outputs, i.e. building a CSV string row-by-row with the
getHeaders()
andgetRow(object)
methods respectively. - Better CSV encoding (proper quoting by default)
API
CsvBuilder([options])
-
headers
String|Array Space separated headers, or array of headers (required) -
delimiter
String The column delimiter. Default','
-
terminator
String The row terminator. Default'\n'
-
quoted
Boolean Quote columns? Defaulttrue
-
alias
Object An object in the format of { "csv header": "object prop" },object prop
will be aliased tocsv header
. Default{}
Methods
createReadStream
(payload): Stream.Readable
CsvBuilder#Creates a readable stream and consumes the payload.
-
payload
Array<Object> Incoming data.
createTransformStream
(): Stream.Transform
CsvBuilder#Creates a transform stream. The stream expects either Objects or JSON.
headers
(headers): this
CsvBuilder#-
headers
String|Array Space separated headers, or array of headers
alias
(header, prop): this
CsvBuilder#Set single or multiple contraints. If header
is an object, it will extend any existing constraints, not replace.
-
header
String|Object Either object {"header": "property"} Or a string "Header" -
prop
String|undefined Property to correspond to header, omit if using object.
virtual
(prop, fn): this
CsvBuilder#Create a virtual property. Virtual properties are treated the same as normal properties. If there is no corresponding header or alias, the virtual will not be present in resulting CSV.
-
prop
String Virtual property name -
fn
(item: any) => any Whereitem
is an element from the incoming data, and the return value is the corresponding value for the virtualized property.
getHeaders
(): String
CsvBuilder#The headers in CSV format
getRow
(item): String
CsvBuilder#Returns the CSV formated row for a given item
.
-
item
Object A n item matching the "schema".
Migration to 1.0.0
-
constraints
attribute in options (for constructor) is deprecated, usealias
instead. -
set(prop, value)
method is deprecated, usealias(prop, value)
instead.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].