• 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: Removing spaces from a list in a Text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing spaces from a list in a Text file


  • Subject: Re: Removing spaces from a list in a Text file
  • From: Peter Baxter <email@hidden>
  • Date: Mon, 5 Nov 2007 17:57:19 +1100

Thanks for your input,


In the end I favoured as much AS as I could get in the script and came up with this result:

set pfile to quoted form of (POSIX path of ((choose file) as text))
do shell script "cat " & pfile & " | tr -d ' ' "
set thisText to the result

set _TempFile to ((path to desktop) & "temp.txt") as text

try
close access file _TempFile -- Make sure the file wasn't accidentally left open
end try

open for access file _TempFile with write permission
set eof file _TempFile to 0 -- clear the file contents
write thisText to file _TempFile starting at eof
close access file _TempFile



On 04/11/2007, at 8:23 PM, Philip Aker wrote:

On 2007-11-04, at 01:58, Philip Aker wrote:

On 2007-11-04, at 01:22, Peter Baxter wrote:

I am looking for a script step that would remove all spaces from a list in a .TXT file that contains a list like the one below.  Everything I tried removes the returns as well

AND ,Julie Anderson,VC7B      ,7,7B,13,9,22,2,  2.00,
,,ART7G     ,7,7G,13,8,21,2,  2.00,
,,VC7O      ,7,7O,16,,16,2,  2.00,
,,ART8B     ,8,8B,12,12,24,2,  2.00,
,,IP8R      ,8,8R,12,13,25,2,  2.00,
,,ART8R     ,8,8R,12,13,25,2,  2.00,
,,ART9O     ,9,9O,11,10,21,2,  2.00,
,,AST10     ,10,,5,20,25,4,  4.00,
,,2ND       ,Yard Duty,,,,0,1,  0.00,
,,,,,,Totals ,,22, 20.00,/23

Try this:

set pfile to quoted form of (POSIX path of ((path to desktop folder as text) & "some.txt"))
do shell script "cat " & pfile & " | tr -d ' ' "

I see that you have non-breaking spaces in that file. So:

set pfile to quoted form of (POSIX path of ((path to desktop folder as text) & "some.txt"))
do shell script "cat " & pfile & " | tr -d \"\\302\\240\" | tr -d ' '"

Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@




Peter Baxter
email@hidden


"My masterpiece? Come on, it's Bolero! Unfortunately, it's empty of
music." -Ravel


 _______________________________________________
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

References: 
 >Removing spaces from a list in a Text file (From: Peter Baxter <email@hidden>)
 >Re: Removing spaces from a list in a Text file (From: Philip Aker <email@hidden>)
 >Re: Removing spaces from a list in a Text file (From: Philip Aker <email@hidden>)

  • Prev by Date: Beta testers needed
  • Next by Date: Re: QuickTime document file in Leopard
  • Previous by thread: Re: Removing spaces from a list in a Text file
  • Next by thread: Re: Removing spaces from a list in a Text file
  • Index(es):
    • Date
    • Thread