KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have many large csv files (1-10 gb each) which I'm importing into databases. For each file, I need to replace the 1st line so I can format the headers to be the column names. My current solution is: using (var reader = new StreamReader(file)) { using (var writer = new StreamWriter(fixed)) { var line = reader.ReadLine(); var fixedLine = parseHeaders(line); writer.WriteLine(fixedLine); while ((line = reader.ReadLine()) != null) writer.WriteLine(line); } } What is a quicker way to only replace line 1 without iterating through every other line of these huge files?
Tags (comma-separated)
Save Edits
Cancel