• 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: Stupify text file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupify text file


  • Subject: Re: Stupify text file
  • From: Matthew Stuckwisch <email@hidden>
  • Date: Wed, 3 Apr 2002 23:31:55 -0600

I have a text file with curly quotes which needs to be stupified back to
straight quotes. TexEdit+ has stupify in its dictionary but I can't seem to
get it to work - I'm getting errors along the lines of Access Not Allowed.

You can do it directly in AppleScript

Alternatively (and in many ways a preference) would be if this could be done
via the Terminal because following the stupification the data is imported
via a Terminal script into mysql.

I know there should be a terminal command for it, and that's leaving my head at the moment, so, let's just do it in AppleScript

on stupify(theText)
repeat
try
set theOff to the offset of string "" in string theText
set theText to (text 1 thru (theOff -1) of string theText) & "\"" & (text (theOff +1) thru (count text in string theText) of string theText)
on error
exit repeat
end try
end repeat
return theText
end stupify

Just repeat the repeat, but instead of "" for the first hard coded string use whatever you want to replace it with (for  you'll keep "\""), but for "" and "" you'll use the replacement string "'". Now, before anyone goes and says "here's a more effecient way" or "here's a bug"...I haven't tested this code yet ;-) but know of a few ways to drop it down to size quite a bit already. Almost time for bed and I wrote this really quickly (and don't even use offset much so I've probably messed up just in my usage of it...es la vida). Though I'm sure webguide would love the other version, just so you know it's not that I -can't- do it...just too tired (high school = no sleep). Basically you should get the idea. And the advantage of this? You don't have to open up another app.

Once you've returned the string you can pass it along to the Terminal for SQL to use.


Matthew Stuckwisch
[AIM/MSN]{GuifaSwimmer} | [Yahoo!]{SapphireTree} | [ICQ]{137477701}
[IRC]{guifa / G}(esperNET / irc.massinova.com)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Stupify text file (From: webguide <email@hidden>)

  • Prev by Date: Re: Get UNIX path of selected file
  • Next by Date: Re: Reading large texts
  • Previous by thread: Re: Stupify text file
  • Next by thread: Re: How do you force Finder to update changes in a folder
  • Index(es):
    • Date
    • Thread