importing list

Alex Tweedly alex at tweedly.net
Thu Mar 9 04:03:28 EST 2006


Jim Ault wrote:

>---------------
>Another approach would have an advantage or two.
>ONE - using a web address like http://website.com would not use the colon as
>a delimiter, since the 'split' command only considers the first occurance
>TWO - if any glitches occurred that added spurious lines that did not match
>an existing field, these would be ignored. (eg. tab, space)
>THREE - if your labels have a leading/trailing space this will get cleaned
>off
>FOUR -- filter rawData without empty
>
>NOTE: I would recommend that you not use "/" in your field label (eg.
>Principal/Director)  can lead to problems later with scripting.
>
>-------------------------------------------------------------
>  
>
>>repeat
>>   put url ("file:/Path/To/Your/File.txt") into rawData
>>    
>>
>     filter rawData without empty
>     split rawData using cr and ":"
>  
>
Jim,  you can't do that (at least, not if I interpreted Liam's email 
correctly).  I'm pretty sure he is saying that the file contains 
multiple "entries", each entry consisting of the multiple "fields".  If 
you had a single entry, then this 'split'-based technique is the one I'd 
use - but it can't be used while there are multiple entries ....  you'd 
finish up with an array element for each field name, containing the data 
for the last entry.

You could keep the outer loop from Devin's code, to create tCurrRecord, 
and then split tCurrRecord


>On 3/8/06 1:56 PM, "Devin Asay" <devin_asay at byu.edu> wrote:
>  
>
>>repeat
>>   put url ("file:/Path/To/Your/File.txt") into rawData
>>   put lineOffset("Name:",rawData) into recStart
>>   if recStart = 0 then exit repeat
>>   put lineOffset("Type:",rawData) into recEnd
>>   put line recStart to recEnd of rawData into tCurrRecord
>>   delete line recStart to recEnd of rawData
>>   replace cr&cr with cr in tCurrRecord -- get rid of empty lines
>>   copy card "template" to this stack --create a new card for the data
>>   go last card
>>   set the itemDelimiter to ":"
>>   repeat for each line tLine in tCurrRecord
>>     put item 2 of tLine into fld (item 1 of tLine)
>>   end repeat
>>end repeat
>>    
>>

-- 
Alex Tweedly       http://www.tweedly.net

-------------- next part --------------
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.2/274 - Release Date: 03/03/2006


More information about the use-livecode mailing list