Comments (3)
Not totally sure. Most the examples have .pipe coming after .write.
There are tests for this so it should work in node 4 and 5 at least. https://github.com/C2FO/fast-csv/blob/master/test/formatting.test.js#L24
var ws = fs.createWriteStream("my.csv");
csv
.write([
{a: "a1", b: "b1"},
{a: "a2", b: "b2"}
], {
headers: true
transform: function(row){
return {
A: row.a,
B: row.b
};
}
})
.pipe(ws);
from fast-csv.
I'm running into this same problem working in node v6.1.0.
from fast-csv.
I think the two different write methods are being conflated. The write method in the inital example is the the write
method that is provided by the node streams api, and should be called one row at a time.
The write report should be changed to.
function writeReport(file, data, cb){
var existsAlready = fs.existsSync(file);
var ws = fs.createWriteStream(file, {flags:'a'});
var csvStream = csv.write(data, {
headers: !existsAlready,
includeEndRowDelimiter: true,
});
csvStream
.on('finish', function(err){
cb(err, file);
})
.pipe(fs.createWriteStream(file, {flags:'a'}));
}
from fast-csv.
Related Issues (20)
- [BUG] `comment` doesn't work when first field in line is escaped
- [BUG]parse csv file when row has datetime data,return data miss second HOT 1
- convert JSON object to CSV string
- [FEATURE] Support transform FormatterOptionsArgs of type 'A -> A | B -> B'
- Documentation for other methods? HOT 1
- Trailing comma behaviour has changed between 4.3.1 and latest
- How to parse a csv file from S3 and upload to S3 without keeping in a memory HOT 4
- [BUG] CSV Streams severely limited in capacity HOT 2
- [FEATURE]sfdx version --verbose --json
- Homepage link on npm 404s HOT 1
- [BUG] The `|` character causes unnecessary quotation of the value HOT 1
- [FEATURE] Is this project dead? HOT 6
- [BUG] : Streaming gets stopped and goes to "end" event if row encounters "numerics at the end of the string" like "something_10". HOT 1
- Can not open the site of docs HOT 1
- [BUG] Getting started doc link is broken HOT 4
- [FEATURE] Parsing row issue HOT 1
- [FEATURE] Move to Coveralls GitHub Action
- [FEATURE] Documentation request: example of exception in on('headers') handler
- [BUG] Breaking changes in the new version 5? HOT 2
- [BUG] Format concats lines when reading from multiple streams to one file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-csv.