Unable to get the Specific column with 2 decimal place

Hi,

I have an issue converting decimal places of a particular column, i am using below script to get the output, but the output is not generating in desired format.

awk -F"," 'BEGIN{OFS=","}{if(NR==0)getline;if ($7 != "") {if ($7 > 0) $7=$7/100 ; {printf "%.2f" $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20 > "2.txt"} } }' "1.txt" ;

I am deviding 7th Column field by 100, and want the output of 7th column with 2 decimal along with other columns.

For example if one value post division is

123.12345

then output should be as

123.12

wihtout rounding up of decimal value.

NR will always be > 0, so that if condition is pointless. Your FMT string is for one single number only, so the output will be very limited. Except for the header (which has an unnecessary comma in the end), your file has only records with 20 fields, so the enumeration of fields needn't be. ($7 > 0) implies ($7 != "") , so the latter can be left out. Try

awk -F"," '
BEGIN   {OFS=","
         OFMT="%.2f"
        }
        {if ($7 > 0) $7=$7/100
        }
1
' /tmp/1.txt

Subtract 0.005 from the $7 result if you want to disable rounding up

Thanks RudiC for your support, I am trying with the code you provided with litle modification but the code is not providing any output,

awk -F"," '
BEGIN   {OFS=","
         OFMT="%.2f"
        }
        {
        {if ($7 > 0) $7=$7/100}
print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20  > 2.txt}
'1.txt

, Please help me to identifying where I am going wrong.
Thanks

1) Modify working solutions STEP BY STEP only! That will enable you to identify and concentrate on the step that goes wrong.

You need to double quote the "2.txt" as you did in your first post.

And, the if ($7 ... line could be written as

$7 > 0     {$7=$7/100}