Copy CSV files to Excel?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Bantymom
Posts: 73
Joined: Fri Aug 27, 2010 4:32 am

Copy CSV files to Excel?

Post by Bantymom » Thu Oct 28, 2010 7:17 am

As you all know by now, I've been getting my feet wet with RunMedia, and now I know just enough to be excited and dangerous at the same time.

At school, we are entering the results of a very important test into a page on the internet. (The state IS going to get the results back to us eventually, but that won't be until after March! and we need the information now.) After completing the information for each student, "Compute scores" is pressed and a report is generated to be printed. This report can also be saved as a CSV file, showing one line for that student and nothing else, and so, generating a separate document for each and every student. This means that for the school to make a useful Excel spreadsheet, someone has to open each one of those CSV files, copy that one line, then paste it into an open Excel doc. When you are talking 700-800 students, that's going to take a long time!

It then occurred to me that this might be a job for... *fanfare* ...RevMedia! Wouldn't RevMedia be able to open each successive CSV file, copy the first line, paste it into an Excell file (or save it in a field to export later), each time pasting the next entry either before or after the previous one?

I'm eager to have a go at this (beginner here, so it will mean a good bit of learning for me), but I certainly don't have the time to devote to it if it isn't even possible (It's after 11:00pm here and I am still preparing for tomorrow's lessons and meetings).

So my question is:
It sounds so simple. Is that the kind of thing revMedia would be good at?

Thanks,
Bantymom
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Copy CSV files to Excel?

Post by Klaus » Thu Oct 28, 2010 10:18 am

Hi Bantymom,

why not go through all CSV files, put the first line & CR into a varialbe, and then write this variable,
which now contains ALL the entries, back to another CSV file, that can be opened in EXCEL "en bloc"?

Pseudocode:

Code: Select all

...
put the files into tFiles
filter tFiles with "*.csv"
## In case they have this suffix

repeat for each line tLine in tFiles
  put line 1 of url("file:" & tLine) & CR after new_list
end repeat
delete char -1 of new_list
## Get rid of trailing CR

put new_files into url("file:all_entries.csv")
...
You get the picture :)

Best

Klaus

Bantymom
Posts: 73
Joined: Fri Aug 27, 2010 4:32 am

Re: Copy CSV files to Excel?

Post by Bantymom » Wed Nov 03, 2010 2:04 am

lol, well, I had a go at it and failed miserably.

I couldn't figure out how to import the csv file to begin with. I know it is obvious to everyone else, but, well, not so obvious the first time you try. I looked up about opening and reading files in the dictionary and couldn't get it to make sense for me. Searching through the lessons, I found THIS about exporting a csv file:

http://lessons.runrev.com/spaces/lesson ... -csv-file-

At the very beginning, it suggests that there was an earlier lesson about importing a csv file, but I couldn't find it.

*sigh*

But thank you very much, Klaus, for trying to get me going in the right direction. I guess I'm just not ready for it yet.

Cheers,
Bantymom (still in good humor and good spirits :) )
Last edited by Bantymom on Wed Nov 03, 2010 3:19 am, edited 1 time in total.
2nd-grade Teacher, Poultry Fancier, Scottish Country Dancer
and Perpetual Beginner

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm

Re: Copy CSV files to Excel?

Post by WaltBrown » Wed Nov 03, 2010 2:38 am

Hi Bantymom.

I don't think you need to open or import a file if you use the URL form to access a file. Klaus' example should work as is with no other preparation, one line at a time.

Walt
Walt Brown
Omnis traductor traditor

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Copy CSV files to Excel?

Post by Klaus » Wed Nov 03, 2010 11:57 am

Yep, Walt is correct! :D

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Copy CSV files to Excel?

Post by bn » Wed Nov 03, 2010 1:13 pm

Bantymom,

I made a little demo stack that
1. shows how to choose a folder and extract the file names from it.
2. using the above choosing the folder of your csv files and getting the first line of them and exporting that to a new file on the desktop.

the scripts are extensively commented.

One thing to watch out for: if you get the csv files from a different operating system then some accented characters are different. If you run into that just ask.

regards
Bernd
Attachments
Files and stuff Banty.livecode.zip
(2.91 KiB) Downloaded 321 times

Post Reply