Excel and awk disagree with CSV results

I have a CSV file that I use in two ways: one using Excel, and the other using awk. Here are the totals of my first 8 columns in Excel:

1) 2640502474.00
2) 1272849386284.00
3) 36785.00
4) 
5) 107.00
6) 239259.00
7) 0.00
8) 7418570893330.00

And here is my conclusion awk:

$ cat /home/jason/import.csv | awk -F "\"*,\"*" '{s+=$1} END {printf("%01.2f\n", s)}'
2640502474.00
$ cat /home/jason/import.csv | awk -F "\"*,\"*" '{s+=$2} END {printf("%01.2f\n", s)}'
1272849386284.00
$ cat /home/jason/import.csv | awk -F "\"*,\"*" '{s+=$8} END {printf("%01.2f\n", s)}'
7411306364347.00

Note that 1 and 2 match exactly, but 8 are disabled for many millions. I assume that the final Excel value is correct, so why does awkthis file process differently?

+3
source share
1 answer

, , . Excel . awk - , , . ( ) , , csv .

, , :

$ echo '"1","10","15","1,000","14"' | awk -F "\"*,\"*" '{print $4}'
1
$ echo '"1","10","15","1,000","14"' | awk -F "\",\"" '{print $4}'
1,000

, " , - .

+3

Source: https://habr.com/ru/post/1774398/


All Articles