I have a structured text file, each information is located by its position(offset) and length, for example, this line is taken from a text file:
H00VLS1 1200 32D1 20140602080524WIRE SPEC DATA
and here is the rules to extract data:
HEADER_ID length(3) offset(1)
PRODUCT_NO length(15) offset(4)
SORT_FIELD length(9) offset(19)
SUFFIX length(9) offset(28)
PERSON_CODE length(5) offset(33)
PROCESS_DATE length(8) offset(38)
MAINTENANCE_DATE length(8) offset(46)
finally, after applying this rules we get this data:
HEADER_ID PRODUCT_NO SORT_FIELD SUFFIX PERSON_CODE PROCESS_DATE MAINTENANCE_DATE
H00 VLS1 1200 32D1 20140 60208 0607WIRE SPEC DA
generated xml file:
<header>
<header_id>H00</header_id>
<product_no>VLS1 1200</product_no>
<sort_feild>32D1</sort_feild>
<suffix>20140</suffix>
<person_code>60208</person_code>
<process_date>0607WIRE</process_date>
<maintenance_date>SPEC DA</maintenance_date>
</header>
Now my question is there a C# class or api to convert my text file to an xml or json file, based on length and offset rules ?
No comments:
Post a Comment