Reputation: 20046
I'm new to C# and WPF. I will need to write a program to collect and display RS232 data and save it as a CSV file. Do I need database or XML? Is there any relevant tutorial anyone could recommend?
Upvotes: 0
Views: 433
Reputation: 6390
Don't know much about RS232, but I gather this is binary data coming off a serial port?
I would question the whole idea of outputing it as a CSV file - text based formats are not ideal for this.
XML is a better choice - you could use Base64 to sort out the encoding issues, and you could structure your document sensibly to meet your purposes.
Another idea, depending on what you're trying to do, might be to use a file based Database. I don't mean MS Access either (Spit!) - look up SQLite.
If someone is really forcing you down a CSV route for binary data, then I suggest you and they need to have a talk about whether this really is, when it comes down to it, really such a great idea.
Upvotes: 0
Reputation: 3370
Around the storage..
Do you want to sort / filter / search the data?
Then I would store it in a SQL Database and export it later on to CSV (using a simple StringWriter).
If you don't want to access the data, just collect it and put it into CSV I would simply write it to CSV as the data comes in.
For reading CSV I would recommend using a LINQ to CSV implementation.
E.g. http://www.codeproject.com/KB/linq/LINQtoCSV.aspx or http://www.thinqlinq.com/Post.aspx/Title/LINQ-to-CSV-using-DynamicObject
Upvotes: 1