← Back to team overview

touch-packages team mailing list archive

Re: [Bug 1498973] Re: sort fails to order correctly on CSV files

 

Hi 
thanks for the fast response. -k2,2 does indeed fix it. Is the functionality of -k2 intentional?
I can't easily give you the complete output from locale as I'm emailing from a phone since the source system is on a secure LAN, but it's all set to en_US.UTF-8.
Many thanksSimon

-------- Original message --------
From: Pádraig Brady <P@xxxxxxxxxxxxxx> 
Date: 23/09/2015  23:06  (GMT+00:00) 
To: simon@xxxxxxxxxxxx 
Subject: [Bug 1498973] Re: sort fails to order correctly on CSV files 

You probably want -k2,2 to restrict the comparison to just that field.
What's the output from `locale` as a matter of interest

-- 
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/1498973

Title:
  sort fails to order correctly on CSV files

Status in coreutils package in Ubuntu:
  New

Bug description:
  Using latest coreutils 8.21-1ubuntu5.1 on Trusty, installed via apt-
  get from the standard repositories.

  Given a file of UK postcodes which includes an erroneous (shorted)
  one, e.g.

  AB234DA
  CA87BJ
  BA23NN
  AB234D
  BA572LD
  AB234DA

  The command 'sort filename' correctly orders the file:

  AB234D
  AB234DA
  AB234DA
  BA23NN
  BA572LD
  CA87BJ

  Note the shorter of the set of "AB234D" matches is at the start of the
  file.

  However, if the file is a .csv file with lines such as:
  "Some string",AB234DA,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1

  ...the command 'sort -k2 -d -t","' doesn't handle the shorter string
  correctly, so it results in:

  "Some string",AB234DA,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",AB234D,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",AB234DA,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",BA23NN,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",BA572LD,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",CA87BJ,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1

  
  Note that AB234D is left between its longer relatives, whereas it should appear first.

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

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to coreutils in Ubuntu.
https://bugs.launchpad.net/bugs/1498973

Title:
  sort fails to order correctly on CSV files

Status in coreutils package in Ubuntu:
  New

Bug description:
  Using latest coreutils 8.21-1ubuntu5.1 on Trusty, installed via apt-
  get from the standard repositories.

  Given a file of UK postcodes which includes an erroneous (shorted)
  one, e.g.

  AB234DA
  CA87BJ
  BA23NN
  AB234D
  BA572LD
  AB234DA

  The command 'sort filename' correctly orders the file:

  AB234D
  AB234DA
  AB234DA
  BA23NN
  BA572LD
  CA87BJ

  Note the shorter of the set of "AB234D" matches is at the start of the
  file.

  However, if the file is a .csv file with lines such as:
  "Some string",AB234DA,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1

  ...the command 'sort -k2 -d -t","' doesn't handle the shorter string
  correctly, so it results in:

  "Some string",AB234DA,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",AB234D,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",AB234DA,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",BA23NN,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",BA572LD,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1
  "Some string",CA87BJ,15,29.1,"another string",45.2,66.7,19,NULL,hello,99,0,1

  
  Note that AB234D is left between its longer relatives, whereas it should appear first.

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


References