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

Support for appending new record to the existing file #194

Closed
GraceYuJuSong opened this issue Oct 4, 2013 · 4 comments
Closed

Support for appending new record to the existing file #194

GraceYuJuSong opened this issue Oct 4, 2013 · 4 comments

Comments

@GraceYuJuSong
Copy link

Current WriteRecord/WriteRecords methods overwrite existing records.
No support for appending new record to the existing file.

@JoshClose
Copy link
Owner

When you open the file, either open in append mode, or open and seek to the end of the file. You can do this all via the FileStream. CsvHelper takes in a TextReader/TextWriter and doesn't know anything about files.

@killnine
Copy link

Just thought I'd mention a detail about this: where it's complicated is when there's a header for a CSV you're writing. That's the situation where having some real 'append' logic would help. However, I'm not sure where that responsibility would lie.

@JoshClose
Copy link
Owner

So you're appending and you have headers, so it writes the header again? Does turning headers off for writing not work in that situation?

@killnine
Copy link

Yeah, the way I was going to resolve was to actually set it via some logic at runtime with an if-check on File.Exists(...).

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