I would like to know a way (of course I want to know the best way) to edit a csv file, preferably without having to read the original and write the results to a new one.
Example 1: I want to split the contents of a column into two columns 123abc into 123, abc
Example 2: I want to remove letters from the beginning of a column AB123 into 123
Clarification: I do not need help solving my examples; I just need to be pointed in the right direction of reading and editing the same file.
Here is a code example of using a temporary file that seems to me is too slow
Dim currentLine as string()
tempFile.AutoFlush = True
Do Until origFile.EndOfData
currentLine = origFile.ReadFields
currentLine(1) = currentLine(1).Replace("ABC","") 'would convert ABC123 to 123
For index as Integer = 0 to currentLine.Count - 2
tempFile.Write(currentLine(index) & ",")
Next
tempFile.Write(currentLine(currentLine.Count - 1))
tempFile.WriteLine()
Loop
tempFile.Flush()
tempFile.Dispose()
origFile.Dispose()
IO.File.Copy(tempFile,OrigFile,True)
IO.File.Delete(tempFile)