0

I have a .txt file that has 3 different sections, a header line, multiple rows of data, and a trailer line. The header line is a series of characters that are bunched together and are decoded by start position and length:

GBGSELLERRTCBM0011120201016 

(Parsed)

GBG|SELLER|RTC|BM|00111|20201016

The data section is parsed roughly the same way but has different data and there are numerous lines of this:

800374000        272      BAXTER                    939330106MILLSJACKH2020100100000000985356100000000000020190000000086474517         F 701072664259000000000184308890812B1                    042N

(Parsed)

8|0037400|0        |272      |BAXTER                    |939330106|MILLSTREYH|20201001|000000009853561|0|000000000002019|00000|00086474517         |F| 7|010|726642590|000000001|843088908|1|2B1            |        0|42N|
|

The trailer record follows the same type of pattern.

I need to read the text file. Parse the first line (probably by using substring) and write that to a sql database. Read through the next (numerous) lines, parse them, then write to database, then read the footer and write to database. Anyone know of a relatively efficient way to do this? VB code examples are a big help but can understand C# as well.

Levi
  • 53
  • 10

1 Answers1

0

in this case you need to use multi-mode and you should identify on mode before start parse, you also need to multi parser for each case you can choose parser deppend on mode.

Hani
  • 149
  • 1
  • 3
  • Would you share some examples of how to do this? I am not familiar with multi-mode or multi-parsing at all. – Levi Oct 19 '20 at 15:08