Hi Guys,
I really am a bit of a muppet at times!
There was I thinking that your references to "DateTime" were a sort of pseudo code reference to me needing to work out how to match the date!
Then after having created some rather untidy if, else if, else awk code which checks for JAN, FEB, MAR... in turn which seemed to work on all but the first row of data, I went back to the input code and lo and behold it quite clearly says "DateTime" in the label. Now I realise why you were questioning what I was up to! Never mind, I've learnt a lot about reg expressions and how bad at them I am!
Anyway, the solution almost works. The code below gives the following output:
Code:
awk '{
while ( getline > 0 ) {
if ( match($0, /DateTime/) ) {
printf "\n%s %s", $5, $6
}
else {
printf ",%s", $5
}
}
printf "\n"
}' dop_gm_emma.txt > dop_gm_tab.txt
,5.45439e+06,-487.407,-672346,9.15808e+08,-6.75078e+11,1.8763e+14
29-JUL-2010 00:08:33.998848,5.45496e+06,-496.71,-663010,8.98857e+08,-6.64175e+11,1.8547e+14
29-JUL-2010 00:08:40.041145,5.45554e+06,-506.013,-653675,8.81907e+08,-6.53271e+11,1.8331e+14
29-JUL-2010 00:08:46.083440,5.45612e+06,-515.316,-644339,8.64956e+08,-6.42368e+11,1.8115e+14
29-JUL-2010 00:08:52.125737,5.4567e+06,-524.619,-635004,8.48005e+08,-6.31465e+11,1.7899e+14
29-JUL-2010 00:08:58.168033,5.45728e+06,-533.922,-625668,8.31054e+08,-6.20562e+11,1.7683e+14
As you can see the first line is missing. The first two records are given below for reference:
009525> DOP_CENTROID_COEFFS_ADS.0.zero_doppler_time.mjd (DateTime) = 29-JUL-2010 00:08:27.956552
009538> DOP_CENTROID_COEFFS_ADS.0.slant_range_time (ns) = 5.45439e+06
009542> DOP_CENTROID_COEFFS_ADS.0.dop_coef.0 (HzHz/sHz/s2Hz/s3Hz/s4) = -487.407
009546> DOP_CENTROID_COEFFS_ADS.0.dop_coef.1 (HzHz/sHz/s2Hz/s3Hz/s4) = -672346
009550> DOP_CENTROID_COEFFS_ADS.0.dop_coef.2 (HzHz/sHz/s2Hz/s3Hz/s4) = 9.15808e+08
009554> DOP_CENTROID_COEFFS_ADS.0.dop_coef.3 (HzHz/sHz/s2Hz/s3Hz/s4) = -6.75078e+11
009558> DOP_CENTROID_COEFFS_ADS.0.dop_coef.4 (HzHz/sHz/s2Hz/s3Hz/s4) = 1.8763e+14
009580> DOP_CENTROID_COEFFS_ADS.1.zero_doppler_time.mjd (DateTime) = 29-JUL-2010 00:08:33.998848
009593> DOP_CENTROID_COEFFS_ADS.1.slant_range_time (ns) = 5.45496e+06
009597> DOP_CENTROID_COEFFS_ADS.1.dop_coef.0 (HzHz/sHz/s2Hz/s3Hz/s4) = -496.71
009601> DOP_CENTROID_COEFFS_ADS.1.dop_coef.1 (HzHz/sHz/s2Hz/s3Hz/s4) = -663010
009605> DOP_CENTROID_COEFFS_ADS.1.dop_coef.2 (HzHz/sHz/s2Hz/s3Hz/s4) = 8.98857e+08
009609> DOP_CENTROID_COEFFS_ADS.1.dop_coef.3 (HzHz/sHz/s2Hz/s3Hz/s4) = -6.64175e+11
009613> DOP_CENTROID_COEFFS_ADS.1.dop_coef.4 (HzHz/sHz/s2Hz/s3Hz/s4) = 1.8547e+14
I altered the code to include the following directly after the while statement (only for debugging) and found it is definitely skipping the first line, but I have no idea why, a goodle search didn't turn anything up either:
009538> DOP_CENTROID_COEFFS_ADS.0.slant_range_time (ns) = 5.45439e+06
,5.45439e+06009542> DOP_CENTROID_COEFFS_ADS.0.dop_coef.0 (HzHz/sHz/s2Hz/s3Hz/s4) = -487.407
,-487.407009546> DOP_CENTROID_COEFFS_ADS.0.dop_coef.1 (HzHz/sHz/s2Hz/s3Hz/s4) = -672346
,-672346009550> DOP_CENTROID_COEFFS_ADS.0.dop_coef.2 (HzHz/sHz/s2Hz/s3Hz/s4) = 9.15808e+08
,9.15808e+08009554> DOP_CENTROID_COEFFS_ADS.0.dop_coef.3 (HzHz/sHz/s2Hz/s3Hz/s4) = -6.75078e+11
,-6.75078e+11009558> DOP_CENTROID_COEFFS_ADS.0.dop_coef.4 (HzHz/sHz/s2Hz/s3Hz/s4) = 1.8763e+14
,1.8763e+14009580> DOP_CENTROID_COEFFS_ADS.1.zero_doppler_time.mjd (DateTime) = 29-JUL-2010 00:08:33.998848
On the off chance it would make a difference, I added a newline at the top of my input file and it now works - what is all that about?!
29-JUL-2010 00:08:27.956552,5.45439e+06,-487.407,-672346,9.15808e+08,-6.75078e+11,1.8763e+14
29-JUL-2010 00:08:33.998848,5.45496e+06,-496.71,-663010,8.98857e+08,-6.64175e+11,1.8547e+14
29-JUL-2010 00:08:40.041145,5.45554e+06,-506.013,-653675,8.81907e+08,-6.53271e+11,1.8331e+14
29-JUL-2010 00:08:46.083440,5.45612e+06,-515.316,-644339,8.64956e+08,-6.42368e+11,1.8115e+14
Anyway, thank you both very much for your help! :-)
Emma