I have below file, number of rows might change to any numbers
Sample .text File
1019893476200 02
5200ABCD company
6218034762001234
799R022408200000
6211934762001134
799R122408200000
8200000002008934
5200ABCD company
6218934762009994
799R042408200000
8200000002008934
9000004000002000
Here
row starts with 1 represents file header,
row starts with 5 represents batch header,
row starts with 6 represents details record,
row starts with 7 represents additional record,
row starts with 8 represents batch trailer record,
row starts with 9 represents file trailer record (this represens end of file and it contains complete file info)
I have below tables with the column as follows
Table 1 - it stores complete file as different rows
FileId(Primary) FileHeader BatchHeader BatchTrailer FileTrailer
1 1019893476200 5200ABCD company 8200000002008934 9000004000002000
2 1019893476200 5200ABCD company 8200000002008934 9000004000002000
Table 2 - it stors row starts with 6 and 7
Detailed(PK) FileId(FK) Number1 Account Code
1 1 03476 0012 R02
2 1 93476 0011 R12
3 2 93476 0099 R04
Note : Number1 - can be find in row starts with 6 - data position starts with 5 and length 5 (example - 03476)
Account -can be find in row starts with 6 - data position starts with 11 and length 4(example - 0012)
code - can be find in row start 7 - data position starts with 4 and length 3 (example - R02)
Question : Using datatable in go llanguage , how do i parse the entire file and how do i populate data in datatable in Go and then pass the same datatable to postgresSQL and insert into tables