08-12-2008
18,
0
Join Date: Jun 2008
Last Activity: 25 March 2009, 11:51 AM EDT
Posts: 18
Thanks Given: 0
Thanked 0 Times in 0 Posts
OK the above works a treat thanks. This leads me to mu next and final issue but will need to explain a little first.
Once the first file (FIRST.CSV) has been generated with codes and ammount column adjustments have to be made to certain accounts. This is done my the use of the second file (SECOND.CSV). If the codes in the first file and second file agree then the amount in the second file is added/substracted to the first file. If the code in the second file does not agree to any code in the first file then the code and amount are appended to bottom:
e.g
FIRST.CSV
A001ZZ ,, 400
A002ZZ ,, 300
SECOND.CSV
A001ZZ ,, -200
A002ZZ ,, 100
A003ZZ ,, 10
THIRD.CSV
A001ZZ ,, 200
A002ZZ ,, 400
A003ZZ ,, 10
The above isd done by using the code:
join -t, -a1 -a2 ${SECOND.CSV} ${FIRST.CSV} > ${THIRD.CSV}
nawk -F, '{ printf $1",," "%011.2f\n",$3+$5 }' ${THIRD.CSV} > ${FINAL.CSV}
The problem with the above is that if for example A001ZZ needs two adjustmentss at the same time meaning the SECOND.CSV file will look like:
SECOND.CSV
A001ZZ ,, -200
A001ZZ ,, 300
A002ZZ ,, 100
A003ZZ ,, 10
my code will only pick up the first instance of A001ZZ and adjust as required and the second occurence of A001ZZ will then be treated as a new code and be appended to the bottom of FINAL.CSV.
Could anyone please assist as to how I can resolve this issue?