[Solved] Data error need to fix

Hi Guys,

I`m having a strange problem with my data set. Whenever there is a transition to another value is col1, the corresponding 3rd col goes to the next line. This is a huge file, so need to fix in a script. The file is tab delimited.

Here is what is happening when transitioning from DS11.02060 to DS11.02061, the value 1150.76 is in the next line. Happens for every transition. The file is sorted by col 1.

DS11.02060    DS11.28178    562.907
DS11.02060    DS11.28179
    1150.76
DS11.02061    DS11.02063    455.141
DS11.02061    DS11.02064    476.496
DS11.02062    DS11.28178    562.957
DS11.02062    DS11.28179
    1170.76
DS11.02063   DS11.02063    235.141
DS11.02063    DS11.02064    445.499

Expected output 

DS11.02060    DS11.28178    562.907
DS11.02060    DS11.28179    1150.76
DS11.02061    DS11.02063    455.141
DS11.02061    DS11.02064    476.496
DS11.02062    DS11.28178    562.957
DS11.02062    DS11.28179    1170.76
DS11.02063   DS11.02063    235.141
DS11.02063    DS11.02064    445.499
awk -F"\t" -v OFS="\t" 'NF==2 { A=$0 ; getline ; print A,$0 }' inputfile > outputfile
1 Like
$ awk 'NF==2{s=$0;next}NF==1{$0 = s FS $0}1' file
1 Like
 awk 'ORS=(NF==2)?FS:RS' myFile
3 Likes

thank you ! everything works great !