c# convert file from one format to another
Posted
by
JOE SKEET
on Stack Overflow
See other posts from Stack Overflow
or by JOE SKEET
Published on 2011-02-03T22:58:43Z
Indexed on
2011/02/03
23:25 UTC
Read the original article
Hit count: 221
i have a bunch of files that need to be converted. the beginning files look like this:
Well ID,Error code,Sample Barcode
A1,0,THC_CAL1
B1,0,THC_CAL2
C1,1,THC_CAL3
D1,0,THC_CAL4
E1,0,THC_QC1
F1,0,THC_QC2
G1,0,THC_QC3
H1,0,THC_QC4
A2,0,BLANK0609
B2,0,AA178121
C2,0,CC37815
D2,0,BLANK0610
E2,0,CC37819
F2,0,N150680
G2,0,BLANK0611
H2,0,AA127900
A3,0,AA26940
B3,0,BLANK0612
...........
the output needs to look like this:
A01 THC_CAL1
B01 THC_CAL2
D01 THC_CAL4 //please note that c1 is gone since it did not have a 0 in the middle column
E01 THC_QC1
F01 THC_QC2
G01 THC_QC3
H01 THC_QC4
A02 BLANK0609
B02 AA178121
C02 CC37815
D02 BLANK0610
E02 CC37819
F02 N150680
G02 BLANK0611
H02 AA127900
A03 AA26940
B03 BLANK0612
H10 BLANK0234 //please notice that there is H10 and not H010
what would be the best way to read this file into a variable and then output this into a new file? should i read it line by line or should i read it into a datatable?
© Stack Overflow or respective owner