I have a program that opens a fixed length delimited file and process each line depending on what it starts with.
Sample Input:
101 000000000 0000000001010271255A094101National Payment Corp National Payment Corp
5200Happy Company ACH20101021-001.txt PPDDIR DEP 101105101105 1000000000000001
622122400724133133133 000002491300000001 Sam L Adams 0000000000000001
622122400724123123123 000007644900000064 Bravo Bennett 0000000000000002
622122400724144144144 000003310600000009 Nora Elizabeth 0000000000000003
627000000000123232233 000013446800009999 DEBIT Happy Company 0000000000000004
820000000400367202160000001344680000001344681731433493
(attached as well)
I need to read the lines that start with "5" and group them until line "8" basically creating a "batch" for each group.. then have it continue processing the file as needed.
I am trying to use a datatable to do it just because some of these files can be very large and i was told that it would be faster processing.
I have this so far:
Which will output the file to the console just as it is in the text file. but i am not sure to get it to group the lines to do more work on them. The lines that start with "1" and "9" are just processed alone.
Thank you for you help in advance
PS i am very new to programming and this application is my first
Sample Input:
101 000000000 0000000001010271255A094101National Payment Corp National Payment Corp
5200Happy Company ACH20101021-001.txt PPDDIR DEP 101105101105 1000000000000001
622122400724133133133 000002491300000001 Sam L Adams 0000000000000001
622122400724123123123 000007644900000064 Bravo Bennett 0000000000000002
622122400724144144144 000003310600000009 Nora Elizabeth 0000000000000003
627000000000123232233 000013446800009999 DEBIT Happy Company 0000000000000004
820000000400367202160000001344680000001344681731433493
(attached as well)
I need to read the lines that start with "5" and group them until line "8" basically creating a "batch" for each group.. then have it continue processing the file as needed.
I am trying to use a datatable to do it just because some of these files can be very large and i was told that it would be faster processing.
I have this so far:
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openFileName As String = ""
openFileName = GetOpenFileName()
If openFileName.Equals("") Then Exit Sub
Dim tbl As New DataTable("mytable")
tbl.Columns.Add("col1", GetType(String))
'tbl.Columns.Add("col2", GetType(String))
'tbl.Columns.Add("col3", GetType(Integer))
Dim myStream As System.IO.StreamReader = New System.IO.StreamReader(openFileName)
Dim line As String
Dim aRow As DataRow
Do
line = myStream.ReadLine()
If line Is Nothing Then
Exit Do
End If
Dim sAry As String() = Split(line, vbCrLf) ' separate the fields of the current row
aRow = tbl.NewRow 'get a DataRow that has the required structure
aRow(0) = sAry(0)
'aRow(1) = sAry(1)
'aRow(2) = CInt(sAry(2))
tbl.Rows.Add(aRow)
Loop
myStream.Close()
For Each aRow In tbl.Rows
Console.WriteLine("{0}", aRow(0))
Next
End Sub
Which will output the file to the console just as it is in the text file. but i am not sure to get it to group the lines to do more work on them. The lines that start with "1" and "9" are just processed alone.
Thank you for you help in advance
PS i am very new to programming and this application is my first