importing list

Devin Asay devin_asay at byu.edu
Wed Mar 8 16:56:41 EST 2006


Liam,

If I understand correctly, your files contain lists like the one in  
your message, which repeat over and over in a single file. So one  
file might have many "records".

This is how I'd approach it:

Create a stack with just one card, a "template" with all the proper  
fields.

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

This is untested but should be mostly right.

Devin

On Mar 8, 2006, at 11:14 AM, liamlambert wrote:

> I have a large amount of plane text files that are laid out like  
> this Below
>
>
> Name:
>
> Roll Number:
>
> Address:
>
> Principal/Director:
>
> Phone:
>
> Fax:
>
> Email:
>
> Website:
>
> Female Enrolment:
>
> Male Enrolment:
>
> Type: Primary
>
> I want to import the info that is after the  colon into fields of  
> the same name as the list above the list repeats name roll number ect
> Liam Lambert
> liamlambert at mac.com
> IRELAND
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list