Stupid CSV tricks

Yennie at aol.com Yennie at aol.com
Sat Jun 15 15:46:01 EDT 2002


Richard,

One other iteration I thought of when I was playing with this...
It simply speeds up the repeat loop with a little itemDelimiter magic:

The thought- the even numbered items are inside quotes, the others are 
outside. Quotes are stripped automagically since they are the delimiters, and 
returns are escaped when they are inside quotes. Commas become tabs when they 
are outside the quotes.

  replace "\"&quote with tEscapedQuotePlaceholder

  put 1 into itemCount
  set the itemDelimiter to quote
  repeat for each item temp in pData
    if ((itemCount mod 2) = 0) then
      ## inside quotes
      ## leave commas alone
      replace cr with tReturnPlaceholder in temp
      put temp after tNuData
    else
      ##outside quotes
      replace comma with tab in temp
      put temp after tNuData
    end if
    add 1 to itemCount
  end repeat


Brian



More information about the metacard mailing list