importing list
Jim Ault
JimAultWins at yahoo.com
Wed Mar 8 23:00:51 EST 2006
---------------
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 ":"
put the keys of rawData into fldnames
>
>
>
> copy card "template" to this stack --create a new card for the data
> go last card
>
repeat for each line FLDNM in fldnames
put word 1 to -1 of FLDNM into FLDNM
if there is a field FLDNM then
put rawData[ FLDNM] into fld ( FLDNM )
end if
end repeat --fld fill loop
> end repeat --main loop
--------------------------------------------------------------------
On 3/8/06 1:56 PM, "Devin Asay" <devin_asay at byu.edu> wrote:
> 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
>
> _______________________________________________
> 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
More information about the use-livecode
mailing list