Re: Total Newbie question
Re: Total Newbie question
- Subject: Re: Total Newbie question
- From: Ricardo Montiel <email@hidden>
- Date: Fri, 15 Jun 2001 13:22:11 -0300
on 14 Jun 2001 08:25:00 -0800, "roblef" at <email@hidden> wrote:
>
I'm looking for a way to clean up text files, from form submissions on the
>
web. With a simple form, we get something like the following:
>
>
name=joe
>
date=january
>
comment=I hate forms
>
>
I'd like to be able to reformat this stuff, either into a spreadsheet or
>
table format, possibly several submissions in a document. Take the <category
>
=xxxxx> out of it altogether. Is this possible with Applescript?
Hi Rob,
Yes, it is possible. For a way to accomplish it, try this vanilla (or pure
AppleScript Language) method:
----- Begin Script ----------------------------------------
set xForm to "name=joe
date=january
comment=I hate forms
name=mary
date=december
comment=me too"
set xForm to my cambiarTexto(xForm, "=", ":\"")
set xForm to my cambiarTexto(xForm, return, "\",")
set xForm to "{" & xForm & "}" as list
set xForm to ((xForm as record) as list)
set xForm to my cambiarTexto(xForm, "", tab)
log xForm
on cambiarTexto(xText, xFind, xChange)
try
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to xFind
set xText to text items of xText
set AppleScript's text item delimiters to xChange
set xText to (xText as text)
set AppleScript's text item delimiters to oldDelims
return xText
on error
set AppleScript's text item delimiters to oldDelims
end try
end cambiarTexto
----- End Script ----------------------------------------
the result:
(*joe january I hate forms
mary december me too*)
---------------------------------------------------------
Is that what you are looking for? Hope this helps,
--
Saludos (Regards),
-- Ricardo Montiel
Buenos Aires, Argentina