reading CSV text file
Jim Ault
JimAultWins at yahoo.com
Fri Jun 22 19:19:55 EDT 2007
Whoops, forgot one line for sure...
> Job 2 is to scan for quotes where readingString = true
> and convert it to numtochar (4)
> false into readingString
> put empty into prevCH
> repeat for each char CH in textBlock
> if (CH is ",") and prevCH is q then
> put false into readingString
> put prevCH after newTextBlock
> else
> put numtochar (3) after newTextBlock
> end if
> if (CH is q) and prevCH is "," then
> put false into readingString
> end if
> end repeat
put CH into prevCH --- IMPORTANT
> put CH after newTextBlock
>
On 6/22/07 4:04 PM, "Jim Ault" <JimAultWins at yahoo.com> wrote:
>> My problem is, i do not know, how can i read the file and detect each item of
>> a line, as the items are sepearated by comma and the textfield/items could
>> contain comma, too. How can i tell Revolution to ignore the comma in the
>> "tesxtarea of an item"
>
> Short answer is to ask for a tab delim file instead.
>
> I have had to do this task before because we bought industry data that was
> only available in CSV. Probably the worst format ever, but everyone seems
> to use it. Tab delim is sooo much better,
>
> Part of the situation is:
> text values with quotes surrounding
> and
> text values with embedded quotes
> text values with embedded commas
>
> Embedded commas are problematic in any solution you program.
> --> Fuji Cleaning Cartridge für DLT Streamer, retail
>
> The basic concept you need to keep is that you are building a character
> scanner with flags to represent conditions.
>
> A reading value w/o quote, thus number (commas illegal now)
> B reading value w/ quote as first char, thus string
> C found quote followed by comma, thus end of string
> D found quote not followed by comma, thus embedded quote
> E reading string, found comma before closing quote, thus embedded comma
More information about the use-livecode
mailing list