【发布时间】:2019-06-03 01:33:49
【问题描述】:
我正在开发 vb.net 应用程序。其中我有多个文本文件,需要根据文件中的某些标识符(重复词)拆分记录。 你能帮我吗,因为我是 vb.net 的新手,不知道该怎么做。 到目前为止我已经编码了
If (Directory.Exists(filePath)) Then
'search file in the input path by their search pattern
For Each File As String In Directory.GetFiles(filePath, "*.txt", SearchOption.TopDirectoryOnly)
Console.WriteLine("Reading the current file " + Path.GetFileName(File))
Using sr As StreamReader = New StreamReader(File)
Dim Currentline As String
Dim Identifier As String
Dim statementDate As String
Dim currenttext As String
'getting the unique identifier from the files and removing the white spaces
Identifier = sr.ReadLine.Substring(69, 8)
'checks until the EOF
While Not sr.EndOfStream
currenttext = sr.ReadLine()
'loop through until identified not repeated
Do Until currenttext.Contains(Identifier)
Currentline = sr.ReadLine()
Console.WriteLine(Currentline)
Loop
Console.WriteLine("=========================== Records Ends")
End While
End Using
另外,这里是需要拆分的文本文件的屏幕截图。
提前致谢。
【问题讨论】: