我有一个文本文件,其中包含以下类型的数据。
"3P","Smith","Richard","3 Point Promotions","3P","richs51@gmail.com","IDA","Yes",,,,0,4,5,83.33,10,
"A1","Ernest","Amy","TAKE 1 Promotional Products","LCOOK","lcpromos@adelphia.net","IDA","Yes",,,,0,6,7,,0,
"A2","Derek","Eaton","Advertising Edge Promotions","AE","dereke@adedgepro.com","IDA","Yes",,,,0,8,8,,10,
"AAA","Abercrombie","Jerry","AAA Specialty Wholesale Inc","AAA","wabercro@bellsouth.net","IDA","Yes",,,,0,9,9,,10,
"AAP","Halberstam","Mendy","All About Promotions","AAP","mendyaap@yahoo.com","IDA","Yes",,,,0,10,10,,12,
每个都是单独的行。现在我想在每个中添加另一个列
"3P","Smith","Richard","3 Point Promotions","3P","richs51@gmail.com","IDA","Yes",,,,0,4,5,83.33,10,**96**
"A1","Ernest","Amy","TAKE 1 Promotional Products","LCOOK","lcpromos@adelphia.net","IDA","Yes",,,,0,6,7,,0,**97**
"A2","Derek","Eaton","Advertising Edge Promotions","AE","dereke@adedgepro.com","IDA","Yes",,,,0,8,8,,10,**98**
"AAA","Abercrombie","Jerry","AAA Specialty Wholesale Inc","AAA","wabercro@bellsouth.net","IDA","Yes",,,,0,9,9,,10,**99**
"AAP","Halberstam","Mendy","All About Promotions","AAP","mendyaap@yahoo.com","IDA","Yes",,,,0,10,10,,12,**100**
我如何逐行阅读内容。以及如何在每行的同一文本文件中写入另一个值。请为此问题发送解决方案。我在等待您的回复。谢谢回复。 -Saravanan
答案 0 :(得分:1)
也许是这样的:
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