populating table with csv data

Marielle Lange mlange at lexicall.org
Fri Apr 14 08:59:21 EDT 2006


Dear Viktoras

You can directly put a data file separated by tabs in a table field  
(put tData into field "somefield"). If your data are separated with  
another separator, then  you need a function to replace that  
separator with a tab. This could be something like that (untested)

   put url ("file:yourfile) into tData
   put csv2tab(tData, ",") into tTabbedData
   put tTabbed data into field "my data field"
         -- I write it as two lines only for clarity, you could do  
this: put csv2tab(tData, ",") into field "my data field"

function csv2tab pData, pSeparator
   if pSeparator is tab then return pData
   set the itemdel to pSeparator
   put empty into tTabbedData
   repeat for each item tItem in pData
       --- this loop is being used to make sure that only the  
separator is replace *only* when outside quotes
       --- the pSeparator should be untouched in "Doe, John"  but  
changed in "Doe", "John"
       put tItem & tab after tTabbedData
   end repeat
   return tTabbedData
end csv2tab

>  Hi!
>
> could someone please point to an example on how to populate table  
> cells with
> data read from a delimited (comma, tab, etc...) text file. Is there  
> any
> specific transcript "shortcut" function to do this or just the  
> manual "long"
> way?
>
> Thanks!
> Best regards
>
------------------------------------------------------------------------ 
--------
Marielle Lange (PhD),  Psycholinguist

Alternative emails: mlange at blueyonder.co.uk,

Homepage                                                            
http://homepages.widged.com/mlange/
Easy access to lexical databases                    http:// 
lexicall.widged.com/
Supporting Education Technologists              http:// 
revolution.widged.com/wiki/





More information about the use-livecode mailing list