0

using c#, open or reading a text file (source csv file) and . Finally, I have to create another csv file for these lines. Should I create a data table and insert each line after processing and finally export the data table to a csv file. OR Create a csv file before starting foreach {} and write to this csv file for each line.

How would you do it?

2
  • I'm lazy StreamWriter with a formatted WriteLine or if it's complicate LinqToCSV assembly Commented Dec 8, 2010 at 13:57
  • I think LinqToCSV requires .net 3.5 or above and I know the machine where they will be running this tool only has .net 2.0 framework. I will look into this. Thanks Kenny Commented Dec 8, 2010 at 14:07

2 Answers 2

1

The stream way is definitely the way to go!

Although a few years old now - I've used this csv reader framework LumenWorks.Framework.IO.Csv in a few projects and it has worked fine..

http://www.codeproject.com/KB/database/CsvReader.aspx

Sign up to request clarification or add additional context in comments.

3 Comments

It's not really old. It's been updated last month to version 3.7.1.
Our company process to adopt new or open source framework is EXTREMELY discouraging, therefore, I wont be able to use this solution.
Probably best to go with a stream reader then if you cannot use this component. You can look at the code and take inspiration from what they have done as opposed to adding a reference to the component. The source code is available.
0

Depends on how big the orignal file is. In general, it helps scalability to stream like your 2nd option - to NOT load something completely into memeory if you don't really know how big it could be.

1 Comment

It could be 100 lines or 1000 lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.