[Bug 1329736] [NEW] When specifying a field separator with {FS=", "}, the separator is not applied tp the first line

IanBall 1329736 at bugs.launchpad.net
Fri Jun 13 11:16:24 UTC 2014


Public bug reported:

I have a csv input file where I want to extract specific fields.  When I cat that file into mawk using the {FS=","} within the brackets,  the first line of output is as if the field separator was still a space instead of the comma that I specified.  From the second line onwards, the comma field separator is honoured.
The first three lines of output from the command I am using are:
$ cat LUN.csv | awk '{FS=","} {print $2","$5","$14","$17","$20","$23","$26","$29","$32","$35","$77","$78","$79","$80","$81","$82","$83","$84","$85","$86","$87","$88","$89","$90","$91","$92","$93","$94","$95","$96","$97","$98}'
60,5;,naa.600601605d212700a1c3b23a8a6ae011;,naa.600601605d212700a1c3b23a8a6ae011;,naa.600601605d212700a1c3b23a8a6ae011],06/02/2014,,,,,,,,,,,,,,,,,,,,,,,,,,,
06/02/2014 12:05:22,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
06/02/2014 12:07:36,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


If I try the command using the -F "," flag instead the first line of output also has the comma field separator honoured.
The first three lines of output from the command I am using are:
$ cat LUN.csv | awk -F "," '{print $2","$5","$14","$17","$20","$23","$26","$29","$32","$35","$77","$78","$79","$80","$81","$82","$83","$84","$85","$86","$87","$88","$89","$90","$91","$92","$93","$94","$95","$96","$97","$98}'
06/02/2014 12:02:59,0.158562,0.106358,3.061710,0.102991,38.801684,2.717995,0.003367,10.031008,0.343715,0,0,0,0,218,10,16,270,0,0,0,0,0,0,47,12,0,2,4,0,0,0
06/02/2014 12:05:22,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
06/02/2014 12:07:36,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0


I would expect that the behaviour of both would be the same, and specifically that of the {FS=","} would be applied to the first line as well as all following lines.

The attached file is the head of the file I am using so you can test.

The version I am using is on kubuntu 13.10, the version information output is:
$ mawk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

compiled limits:
max NF             32767
sprintf buffer      2040

** Affects: mawk (Ubuntu)
     Importance: Undecided
         Status: New

** Attachment added: "LUN.csv"
   https://bugs.launchpad.net/bugs/1329736/+attachment/4130956/+files/LUN.csv

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to mawk in Ubuntu.
https://bugs.launchpad.net/bugs/1329736

Title:
  When specifying a field separator with {FS=","}, the separator is not
  applied tp the first line

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mawk/+bug/1329736/+subscriptions



More information about the Ubuntu-server-bugs mailing list