Import Excel Data into Property List

Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default Import Excel Data into Property List

    I'd like to be able to import an excel table into director and make a property list out of it. I'd like to be able to access the data like a database table. I assume that saving the excel file as a comma or tab delimited file is the best way to start, but I don't know how to get the info out of the text file and into a list in director. I tried importing the text file as a cast member and then using the value() function to turn it into a list, but that didn't work.

    The tab delimited text file has about 150 records and looks like:
    Prod001 29 80.01 33.21% Yes Low cost
    Prod002 33 79.99 29.01% No High cost
    ....

    the script I used that didn't work looks like:
    on startMovie
    list=value(member("textfile").text)
    if listP(list) then
    gData = list
    else
    alert "Not a List"
    end if
    end

    I tried variations on the syntax but I always get the error "Not a List"

    Any Help would be greatly Appreciated.

    Thanks, Colin



    ctp webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Import excel data into SQL server -- ASP.net, C#, DTS -- how??
      I want to set up the import of data from an excel file into SQL Server from my ASP.net (C#) application. The user will select the file that needs...
    2. import from excel
      Goal: How to import data from an excel file to an oracle or access db. Help needed. tc
    3. Problems with Excel Data-Import
      Dave What about control of the grid lines? Can you turn them off or vary their line weight like in Excel? gbsales
    4. Find the biggest value property in a property list
      Hello the group If I have a list like; You can see there's three properties that are simalar '1.1' & '1.2' & '1.3' Question 1: Now if...
    5. Need to import data to excel
      Is there a way to import the data in xml file to excel spreadsheet as well as provide required formatting on the data. I have excel 2000. Thanks...
  3. #2

    Default Re: Import Excel Data into Property List

    "ctp" [email]webforumsuser@macromedia.com[/email] wrote:
    > I'd like to be able to import an excel table into director and make a property list out of it.
    Hi, Colin. If you don´t need this to be done on the fly, then you can
    select the Excel table, copy it, paste it in Word as a table, select all
    the table, convert it to text separated by items, select all, copy /
    paste into Director and the result is a text member delimited by some item.

    HTH,
    --
    Agustín María Rodríguez | [email]agustin@OnWine.com.ar[/email] | [url]www.OnWine.com.ar[/url]

    Agustín María Rodríguez Guest

  4. #3

    Default Re: Import Excel Data into Property List

    I can get the excel file into a tab or comma delimited file OK, but I need to get that file into a list in Lingo so I can acess each cell of information separately. ie the tab delimited text file looks like:

    Prod001 29 80.01 33.21% Yes Low cost
    Prod002 33 79.99 29.01% No High cost
    ....

    I need to turn this into a list that looks like:
    list=[["Prod001","29","80.01","33.21%","Yes","Low cost"],["Prod002","33","79.99","29.01%","No","High cost"],...]

    so I can access the info pieces:
    newtext=string(list[1][1]) && string(list[1][6]) && "vs." string(list[2][1]) && string(list[2][6])
    put newtext -- "Prod001 Low cost vs. Prod002 High cost"

    Or if anybody knows a better way to do this without using an expensive xtra, I'd appreciate the advice.



    ctp webforumsuser@macromedia.com Guest

  5. #4

    Default Re: Import Excel Data into Property List

    I can get the excel file into a tab or comma delimited file OK, but I need to get that file into a list in Lingo so I can acess each cell of information separately. ie the tab delimited text file looks like:

    Prod001 29 80.01 33.21% Yes Low cost
    Prod002 33 79.99 29.01% No High cost
    ....

    I need to turn this into a list that looks like:
    list=[["Prod001","29","80.01","33.21%","Yes","Low cost"],["Prod002","33","79.99","29.01%","No","High cost"],...]

    so I can access the info pieces:

    on turnIntoList thefilepath
    -- read the file
    inst = new(xtra "fileio")
    inst.openFile(thefilepath,1)
    stringErr = inst.error(inst.status())
    if stringErr <> "OK" then
    alert stringErr
    return ""
    end if
    txt = inst.readFile()
    if stringErr <> "OK" then
    alert stringErr
    return ""
    end if
    inst.closeFile()
    -- parse the text
    lins = the number of lines of txt
    the itemDelimiter = TAB
    theList = []
    repeat with x = 1 to lins
    subList = []
    oneLine = txt.line[x]
    if x = lins and (oneLine = "") then exit repeat
    items = the number of items of oneLine
    repeat with y = 1 to items
    append subList,oneLine.item[y]
    end repeat
    append theList,duplicate(subList)
    end repeat
    return theList

    Put in movie type of script and call like so:

    theList = turnIntoList("C:\folder\tabbedData.txt")


    put theList
    -- [["Prod001", "29", "80.01", "33.21%", "Yes", "Low cost"], ["Prod002", "33", "79.99", "29.01%", "No", "High cost"]]


    Gretchen Macdowall
    updateStage, inc.
    Gretchen webforumsuser@macromedia.com Guest

  6. #5

    Default Re: Import Excel Data into Property List

    Thank you Gretchen, that's exactly what I was looking for.

    There is one (very minor) strange thing that seems to be happening with this script: it puts the RETURN from the end of each line on the text file into the first item of the next line. So if the text file looks like:
    Prod001 12 34 56
    Prod002 78 90 12
    Prod003 34 56 78
    ....
    and I want to output :
    "Prod001 vs. Prod002" (on one line) with:
    string=theList[1][1] && "vs." && theList[2][1]
    it actually outputs:
    "Prod001 vs.
    Prod002" (two lines)

    Like I said, very minor detail, and should be easy enough to fix


    ctp webforumsuser@macromedia.com Guest

  7. #6

    Default Re: Import Excel Data into Property List

    Change this:

    if x = lins and (oneLine = "") then exit repeat

    to this:

    if oneLine = "" then next repeat


    Gretchen Macdowall
    updateStage, inc.
    Gretchen webforumsuser@macromedia.com Guest

  8. #7

    Default Re: Import Excel Data into Property List

    Actually the last fix won't fix it, although it will prevent blank lines in the data from being put on the list. I think the prob is that the file was created on Win and has cr,lf line endings. Lingo likes Mac (cr only) line endings. Here's a fix:

    repeat with y = 1 to items
    oneItem = oneLine.item[y] -- new
    if charToNum(oneItem.char[1]) = 10 then oneItem = oneItem.char[2..length(oneItem)] -- new
    append subList,oneItem -- new


    Gretchen Macdowall
    updateStage, inc.
    Gretchen webforumsuser@macromedia.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139