Importing data into RevDB

Jim Ault jimaultwins at yahoo.com
Sat Dec 5 16:50:33 EST 2009


On Dec 5, 2009, at 5:24 AM, Thomas McGrath III wrote:

> I'm sure others have known about this but I feel like someone just  
> turned on a giant light bulb in my head. This is the single best  
> thing I have learned this year...
>
> set the linedelimiter to comma
> set the itemdelimiter to quote

> I am just amazed...
>

A note of caution when using this.
The chunking rules for Rev are that a line can contain items, but  
items cannot contain lines.
Lines can contain items, items contain words.
   wrong =  line 6 of item 4, no matter the delimiter

Not all functions obey a new setting.
Filter does not follow the linedelimiter, and always uses CR, as does  
Sort.

   wrong  = set the worddelimiter to comma
... since the Rev definition for a word delimiter is white space, not  
a single character.

I have found this useful on occasion when extracting data (such as CSV  
and html) to handle 'embedded returns' in order to keep logical groups  
of amorphous data together.  Another use is to demark field content as  
lines such as

write the contents of the fields of a card to a text file

set the lineDel to "^"
put field "Title" into outputBuffer
put field "Description" into line 2 of outputBuffer
put field "Inventory" into line 3 of outputBuffer
put field "Prices" into line 12 of outputBuffer
set the lineDel to cr
put outputBuffer into url ("file:" & aPath & aFilename)

Also as a utility function to make a run of characters.
put characterString("*", 25) into line 2 of field "studentNotes"
put characterString(space, 10) after line 6 of field "studentNotes"

function characterString charToUse, stringLength
    set the lineDel to charToUse
    put charToUse into line stringLength of tempp
    return tempp
end characterString
    -- now that we are leaving this function
    -- the lineDel setting evaporates
    -- it only applies to this function
    -- the same way itemDel behaves
The same thing can be done with itemDel

    set the itemDel to "^"
    put "^" into item 25 of tempp
    set the itemDel to comma

Hope this helps,

Jim Ault
Las Vegas



More information about the Use-livecode mailing list