Hi,
I need to parse flat text file (without delimiter) using the list of index values (Start Index, End Index).
For e.g. Flat File content
123 Name1 Address1 Class1 Grade1 ....
456 Name2 Address1 Class2 Grade2 ....
789 Name3 Address1 Class3 Grade3 ....
.....
.....
Now, I've dictionary object which has key pair values of each of the fields. (populated from Backend/config. I'm using dictionary o/w we can use array of array, list as well)
<key, value[startindex,endindex])
<id,[0,5]="">
<name,[6,17]>
<address,[18,35]>
<class,[36,43]>
<grade,[44,50]>
My Student Class having 5 properties : Id, Name, Address, Class, Grade
(My Dictionary Key and Class Property Names are Same)
Now, I want to process the file line by line, get all 5 property values populated from each line and store into my Student class Object. Thus, end up having list of student list (in above ex. - list will have 3 items at end of the process)
Perhaps we can use TextFieldParser and foreach loop but in real time my file will have ~40-50 attributes and No. of line can be 10 to 1000+.
Hence, I'm looking for efficient way to parse each line, extract value for each field using index values, create object out of it.
Thanks for your help.
What I have tried:
TextFieldParser and ForEach loop to read file line by line extract values using start/end index.