tags:

views:

15

answers:

1

Hi,

I am having one text file which contain following kind of data.

"3P","Smith","Richard","3 Point Promotions","3P","[email protected]","IDA","Yes",,,,0,4,5,83.33,10,
"A1","Ernest","Amy","TAKE 1 Promotional Products","LCOOK","[email protected]","IDA","Yes",,,,0,6,7,,0,
"A2","Derek","Eaton","Advertising Edge Promotions","AE","[email protected]","IDA","Yes",,,,0,8,8,,10,
"AAA","Abercrombie","Jerry","AAA Specialty Wholesale Inc","AAA","[email protected]","IDA","Yes",,,,0,9,9,,10,
"AAP","Halberstam","Mendy","All About Promotions","AAP","[email protected]","IDA","Yes",,,,0,10,10,,12,

Each of them are separate line.Now i want add another column in each like this

"3P","Smith","Richard","3 Point Promotions","3P","[email protected]","IDA","Yes",,,,0,4,5,83.33,10,**96**
"A1","Ernest","Amy","TAKE 1 Promotional Products","LCOOK","[email protected]","IDA","Yes",,,,0,6,7,,0,**97**
"A2","Derek","Eaton","Advertising Edge Promotions","AE","[email protected]","IDA","Yes",,,,0,8,8,,10,**98**
"AAA","Abercrombie","Jerry","AAA Specialty Wholesale Inc","AAA","[email protected]","IDA","Yes",,,,0,9,9,,10,**99**
"AAP","Halberstam","Mendy","All About Promotions","AAP","[email protected]","IDA","Yes",,,,0,10,10,,12,**100**

How i read content in line by line.And also how to write another value in same text file at each line.Please send solution for this problem.I am waiting for your reply.Thanks for reply. -Saravanan

+1  A: 

Maybe something like this:

Dim lines() As String
Using reader As New IO.StreamReader(filePath)
     Dim sep() As String = {vbNewLine}
     lines = reader.ReadToEnd().Split(sep, StringSplitOptions.RemoveEmptyEntries)
End Using
Dim Index as Int32 = 1
Using writer As New IO.StreamWriter(filePath, False)
     For Each line As String In lines
          writer.WriteLine(line & "," & Index.ToString())
     Next
End Using
ho1