Text file to CSV file
-
-
How can I read the text file from different position say from position 03(column 1), position 04 to 19 (column2) ..and so on. till the length of record.Then how can I get the values and write the values in csv format?.Please Help out. C.Sridevi
Have you looked at the classes in the System.IO namespace? The File class has static methods for reading and writing text data to files. I suggest you read the documentation and attempt to write some code based on the examples in MSDN. If you have any specific problems after doing this, come back and ask again. Paul
-
Have you looked at the classes in the System.IO namespace? The File class has static methods for reading and writing text data to files. I suggest you read the documentation and attempt to write some code based on the examples in MSDN. If you have any specific problems after doing this, come back and ask again. Paul
-
I could read and write the line using stream reader and stream writer.But I need to get the values from a column in a text file.After getting those column values,i need to write it in csv format..how i do this? C.Sridevi
Hi, Here is how to read the file in one chunk (very fast):
Dim inString As String Dim stringArray() As String fileReader = New System.IO.StreamReader(FileName) inString = fileReader.ReadToEnd() fileReader.Close() stringArray = inString.Split(vbLf)
You will then have to parse each line, in stringArray, separating fields at the relevant points. That is where you will have to do the work. What you have asked for does not have a quick and easy answer. Read up on CSV file formats via google then apply your VB .Net knowledge to parsing each line. Hope this helpsYou always pass failure on the way to success.
-
Hi, Here is how to read the file in one chunk (very fast):
Dim inString As String Dim stringArray() As String fileReader = New System.IO.StreamReader(FileName) inString = fileReader.ReadToEnd() fileReader.Close() stringArray = inString.Split(vbLf)
You will then have to parse each line, in stringArray, separating fields at the relevant points. That is where you will have to do the work. What you have asked for does not have a quick and easy answer. Read up on CSV file formats via google then apply your VB .Net knowledge to parsing each line. Hope this helpsYou always pass failure on the way to success.
-
There is no need to write a parser to split the lines into a string array. Look at the Microsoft.VisualBasic.FileIO.TextFieldParser class. It will parse fixed width or CSV text files a line at a time.
Thanks for that. Oh man - I wrote a csv classs to read and write csv files:wtf: I guess I learnt about csv files in the process though:sigh:
You always pass failure on the way to success.