text files with quotes --- thanks!

BCE mark at bcesouth.com
Thu May 16 05:46:00 EDT 2002


David, Jan & Geoff,

Thanks so much for the great code ideas --- and yes, I agree that the status
becomes moot when the execution is so fast!

Thanks again!!!

Mark


----- Original Message -----
From: "David Vaughan" <drvaughan55 at mac.com>
To: <use-revolution at lists.runrev.com>
Sent: Thursday, May 16, 2002 5:39 AM
Subject: Re: text files with quotes


> Jan, Geoff, Mark
>
> You know, it's an interesting thing,  but Mark's original script
> executes at about the same rate (~50 to 70 milliseconds per thousand on
> my Tibook) as do mine, Geoff's and Jan's, simply by making the same
> three basic changes to Mark's script as we all assumed for our own
> variations -  using variables and not fields for operations, and
> ditching the "repeat with x = 1 to N"  together with the "put <status>
> into field whatever" (who needs status when execution is so fast?).
>
> Within that, the original and offered solutions provide some variations
> in operation and output that should keep Mark entertained for a while,
> but the three basic lessons are very clear. Practically a mantra.
>
> cheers
> David
>
>
> On Thursday, May 16, 2002, at 07:25 , Jan Decroos wrote:
>
> > Maybe this can help...
> >
> > the parseItems handler will pass an item to DoStuff only when it's
> > completed
> > (i.e. when one of the prev. items was started with a quote, all items
> > are
> > gathered until we find an item ending with a quote, or when there are no
> > quotes).
> > Maybe you should strip the leading and the ending spaces too.
> >
> >
> > -- the button script
> > on mouseUp
> >   parseItems cd fld 1   -- my data was in field 1
> > end mouseUp
> >
> > on parseItems pData
> >   repeat for each line lLine in pData
> >     put empty into lRealItem
> >     repeat for each item lItem in lLine
> >       if (char 1 of litem = quote) then
> >         if (last char of litem = quote) then
> >           DoStuff lItem
> >         else
> >           put lItem into lRealItem
> >         end if
> >       else
> >         if (lRealItem <> empty) then
> >           put comma&lItem after lRealItem
> >           if (last char of litem = quote) then
> >             DoStuff lRealItem
> >             put "" into lRealItem
> >           end if
> >         else
> >           DoStuff lItem
> >         end if
> >       end if
> >     end repeat
> >   end repeat
> > end parseItems
> >
> > on DoStuff pItem
> >   answer pItem
> > end DoStuff
> >
> >
> > Jan
> >
> >> Anyone have a good method of parsing a text file that is delimmited by
> >> commas, yet has quotes (") surrounding SOME of the records, which in
> >> turn
> >> may have commas inside of them (such as a notes field)?  (!)
> >>
> >> The only routine I made for this was long and ugly, taking a second per
> >> record.  I first replaced commas inside of quotes with a blank space,
> >> then
> >> got rid of the quotes, then parsed by comma.
> >>
> >> Is there a routine I might be missing?  Thanks!
> >>
> >> Mark
> >>
> >
> > _______________________________________________
> > use-revolution mailing list
> > use-revolution at lists.runrev.com
> > http://lists.runrev.com/mailman/listinfo/use-revolution
> >
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list