Preve,
According to your question on reading and writing CSV file and using in text fields, I would like to provide you the points as follows:
1. CSV is just coma delimited plain text file. if the field contains coma, you cna use double quote around it. Such as:
1024, "test, another test", nothing
Basically you need to parse/write such format. if there's no ',' coma in your fields, it's just trivial. You can read each line, use string.split(',') to get all fields into string[]
Then you can use StreamWriter.Writeline(string.format("{0},{1},{2},{3},{4}",fields[0],fields[3],fields[5],fields[4]) to convert the 6 fields to 5 fields as you presented above.
For further discussion on the topic, please take a look at the following thread:
Format CSV using C#
2. I would like to recommend you to take a look at the CSV importer in this article: Import Table - CSV
CSV refers to a family of ASCII (plain text) formats that save tabular data in the form of one line per record with the values for each field in that record separated by a delimiting character. The comma is most frequently used as a delimiter, hence the name Comma Separated Value (CSV) format. Files that use characters other than commas, such as tab characters or some other character, are not "CSV" files as a matter of strict nomenclature and often use a different three letter extension such as .txt or .tab. Manifold's CSV importer can handle most such cases.
There is considerable variation in how different programs work with "CSV" format. Some programs like to see a comma at the end of each line and others do not. Most programs expect to see only string field values enclosed in quotes, but some like to see all values enclosed in quotation marks whether they are strings or not. Manifold's CSV exporter provides options to deal with both situations.
The CSV importer (due to a limitation of the Microsoft driver used) can only import CSV files from read/write media such as hard disks. It cannot import a CSV file from read-only media such as CDs, nor can it import a file from a folder in which we do not have write permission. In such cases, we must copy the file from the originating folder into a working folder in which we have read/write permissions. For example, we might copy a file from a CD onto a folder on our hard disk.
3. There is an example in code project on the more complicated issue, hope the can provide you some idea:
A Fast CSV Reader
One would imagine that parsing CSV files is a straightforward and boring task. I was thinking that too, until I had to parse several CSV files of a couple GB each. After trying to use the OleDB JET driver and various regular expressions, I still ran into serious performance problems. At this point, I decided I would try the custom class option. I scoured the net for existing code, but finding a correct, fast, and efficient CSV parser and reader is not so simple, whatever platform/language you fancy.
Hope that can help you.
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.