• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sort Array by Column X
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sort Array by Column X


  • Subject: Re: Sort Array by Column X
  • From: "Mark J. Reed" <email@hidden>
  • Date: Wed, 21 Jul 2010 09:20:39 -0400

Unless you have commas in your quoted strings, just using comma as the
delimiter works fine.  If you do have commas in your quoted strings,
you need full-on CSV parsing of the sort provided by a full-on CSV
parser.  Might I suggest scripting your favorite spreadsheet program
to load the file and sort the resulting cells by the desired column?



On Wed, Jul 21, 2010 at 8:46 AM, Richard Lake
<email@hidden> wrote:
> Didn't try this as your delimiter is simply a comma whereas my fields having
> quote marks surrounding them.
> set column_id to 5
> set posix_path_to_csv to POSIX path of ((path to scripts folder) &
> "formdb.csv" as string)
> set delimiter to quoted form of (quote & "," & quote)
> set sorted_file to do shell script ("sort -n -t " & delimiter & " -k " &
> column_id & " " & posix_path_to_csv)
> Trying alternative delimiter strings, but keep facing the same error:
> error "sort: multi-character tab `\",\"'" number 2
> On 21 Jul 2010, at 12:35, Steve Thompson wrote:
>
> set column_id to 2
> set posix_path_to_csv to "/Users/steve/testfile.csv"
> set sorted_file to do shell script ("sort -n -t , -k " & column_id & " "
> & posix_path_to_csv)
>
> Thanks
>
> Richard Lake
> Marketing Manager
> Tel: 0800 158 3898 | Email: email@hidden
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>



--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Sort Array by Column X
      • From: Tommy Bollman <email@hidden>
References: 
 >Sort Array by Column X (From: Richard Lake <email@hidden>)
 >Re: Sort Array by Column X (From: Steve Thompson <email@hidden>)
 >Re: Sort Array by Column X (From: Richard Lake <email@hidden>)
 >Re: Sort Array by Column X (From: Steve Thompson <email@hidden>)
 >Re: Sort Array by Column X (From: Richard Lake <email@hidden>)

  • Prev by Date: Re: AppleScript-Users Digest, Vol 7, Issue 370
  • Next by Date: Re: Sort Array by Column X
  • Previous by thread: Re: Sort Array by Column X
  • Next by thread: Re: Sort Array by Column X
  • Index(es):
    • Date
    • Thread