Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending seems to overwrite file #16

Closed
kcbanner opened this issue Jul 9, 2011 · 3 comments
Closed

Appending seems to overwrite file #16

kcbanner opened this issue Jul 9, 2011 · 3 comments

Comments

@kcbanner
Copy link

kcbanner commented Jul 9, 2011

I'm trying this:

var fields = 'some,data,values';
var file = csv().from(fields).toPath('posts.csv', {flag: 'a'});

However, the posts.csv file gets overwritten and only contains the data in the fields variable, and none of its previous contents. I was expecting that fields be appended to the end of the file.

@kcbanner
Copy link
Author

kcbanner commented Jul 9, 2011

Ah, the parameter needed to be flags and not flag as mentioned in the readme.

@d-adamkiewicz
Copy link

On my vista/cygwin box when {flags:'a'} (thanks for the tip;) next appending starts from last line (not a new one) say
last (and only) line is:
3,'ala','ma','kota'
after next appending this file will be:
3,'ala','ma','kota',4,'ola','ma','psa'
5,'janek','ma','szczura'
notice: these should be a 3 lines while there are 2

@wdavidw
Copy link
Member

wdavidw commented Sep 5, 2011

Sorry about the delay, i missed this report while i was on hollidays. I just updated the readme to fix the flags typo. Considering Adam comment, this is somewhat expected since the last line of the csv isn't ended by a line break. I'm not sure what to do with this one, but a solution would be sth like:

var test = csv()
.transform(function(data, index){
    if(index===0){
        test.write('\n',true);
    }
    return data;
})
...;

@wdavidw wdavidw closed this as completed Sep 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants