Spreadsheet to variables
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Spreadsheet to variables
OK I am a real NOOB but I have taken several examples from other projects and built a pretty neat tool. (This LiveCode makes me feel like a genius ) But Now I need something new and wonder if it is over my head right now.
My client gives me a spreadsheet of name,title,number,other in columns.
I need to read each of these in one row at a time into 4 variables, display them, wait for next cue and call up the next row.
Rinse and repeat several hundred times for a presentation.
How hard is this?
I would be happy to send out some beer money for help
Thanks,
Steve
My client gives me a spreadsheet of name,title,number,other in columns.
I need to read each of these in one row at a time into 4 variables, display them, wait for next cue and call up the next row.
Rinse and repeat several hundred times for a presentation.
How hard is this?
I would be happy to send out some beer money for help
Thanks,
Steve
-
- VIP Livecode Opensource Backer
- Posts: 9837
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Spreadsheet to variables
Excel is a complex, proprietary format. If your client could send you a tab-delimited export from the spreadsheet, it would be very easy to work with that data in LiveCode (see the itemDelimiter property in the Dictionary).
If you must work with Excel's format, you may want to consider relying on others who've already done the heavy lifting on parsing it - there's a library for this in the LiveCode store:
http://livecode.com/store/marketplace/excel-library/
If you must work with Excel's format, you may want to consider relying on others who've already done the heavy lifting on parsing it - there's a library for this in the LiveCode store:
http://livecode.com/store/marketplace/excel-library/
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Spreadsheet to variables
No problem I can easily export the xls as a csv. It is just text.
Is that easier?
Thanks,
Steve
Is that easier?
Thanks,
Steve
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Spreadsheet to variables
Hi.
What Richard said.
If you are well on you way to learning LC, does this help?:
What do you mean by "wait for the next cue"? Is it a mouseClick? Is it a keypress? If a mouseClick, you can just:
wait until the mouseClick
If a keypress:
wait until the optionKey is down --or whatever
Waiting is blocking, but in this project that does not seem to matter. Or does it? Do you know what "blocking" means?
Craig Newman
What Richard said.
If you are well on you way to learning LC, does this help?:
Code: Select all
set the itemDelimiter to tab
repeat with y = 1 to the number of lines of yourData
put item 1 of line y of yourData into tname
put item 2 of line y of yourData into tTitle
put item 3 of line y of yourData into tNumber
put item 4 of line y of yourData into tOther
put tName & return & ttitle & return & tNumber & return & tOther into fld "display"
cueThingHere --see below
end repeat
What do you mean by "wait for the next cue"? Is it a mouseClick? Is it a keypress? If a mouseClick, you can just:
wait until the mouseClick
If a keypress:
wait until the optionKey is down --or whatever
Waiting is blocking, but in this project that does not seem to matter. Or does it? Do you know what "blocking" means?
Craig Newman
Re: Spreadsheet to variables
OK I think I get want you have.
Yes I would have a button to advance to the next line.
still noob questions-
How do I get the CSV into this script? I have not done anything with external files yet.
what if I wanted a + and - type of function to go through the data up and down. I would do some math on the y number?
Thanks a lot, I just jumped into this and am doing some more of the tutorials now, I just could stop myself from making something. Now I am building something that I can use.
Steve
Yes I would have a button to advance to the next line.
still noob questions-
How do I get the CSV into this script? I have not done anything with external files yet.
what if I wanted a + and - type of function to go through the data up and down. I would do some math on the y number?
Thanks a lot, I just jumped into this and am doing some more of the tutorials now, I just could stop myself from making something. Now I am building something that I can use.
Steve
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Re: Spreadsheet to variables
SteveSpaw wrote:How do I get the CSV into this script?
Code: Select all
on mouseUp
answer file "select the CSV file"
if it = "" then
exit mouseUp
else
put url ("file:" & it) into yourData
end if
--do something with 'yourData' here!
end mouseUp
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Spreadsheet to variables
Hi..
Many different ways, just go get it. One way, look up the "answer file" command in the dictionary. It would go something like:
If you want to have some sort of interaction as you mentioned with your data once you download it, I think you should place it into, say, a table field, and use standard tools from there. It would be possible to do this in a running handler, but it would be more robust to deal with a field full of data. Less juggling and more easily maintained.
So, how are you going to go about all this? Write back at any time with problems, less so with requests for solutions. We have infinite patience for the former. Build, practice, fail, triumph. That is how you must learn to program.
Craig
Many different ways, just go get it. One way, look up the "answer file" command in the dictionary. It would go something like:
Code: Select all
on mouseup
answer file" Which File?"
put it into tFile
open file tFile
read from file tFile until EOF
close file tFile
answer it
end mouseup
So, how are you going to go about all this? Write back at any time with problems, less so with requests for solutions. We have infinite patience for the former. Build, practice, fail, triumph. That is how you must learn to program.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Spreadsheet to variables
By the end of next week you'll be feeling like a god!(This LiveCode makes me feel like a genius )
Working with .cvs and liveCode is an awesome combination.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 9837
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Spreadsheet to variables
If you have a choice, tab-delimited is much saner than CSV:
http://www.fourthworld.com/embassy/arti ... t-die.html
http://www.fourthworld.com/embassy/arti ... t-die.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Spreadsheet to variables
Wow I hate you guys! I only got 2 hours of sleep last night working on this and NOW with this great info - I can't get away. It is a tractor beam.
Thanks a lot !!!!
Very helpful info.
Steve
Thanks a lot !!!!
Very helpful info.
Steve
-
- VIP Livecode Opensource Backer
- Posts: 9837
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Spreadsheet to variables
WARNING: The Surgeon General has determine that continued exposure to LiveCode can lead to addiction.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn