Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programming question

Status
Not open for further replies.

electroRF

Member
Hi,

I'd appreciate your advice please.

I got a huge spreadsheet which contains which classrooms where taken by which teachers on which dates:
(A class room can be free on certain days, not taken by any teacher)

Code:
Date Taken ----- Date Released ------ Class Room ----- Teacher

01/01/2014 -----  03/01/2014   ------    10      ----- Tony Moore
01/01/2014 -----  02/01/2014   ------    13      ----- Joe Allan
02/01/2014 -----  06/01/2014   ------    11      ----- David Gerrero
03/01/2014 -----  05/01/2014   ------    10      ----- Eddie Corrie
....

I want to convert it into the following format:
(for the entire year of 2014, and for 2015 up to now)

Code:
                       01/01/2014         02/01/2014       03/01/2014       04/01/2014       05/01/2014       06/01/2014
Class Room
10                     Tony Moore         Tony Moore       Tony Moore      Eddie Corrie     Eddie Corrie          Free
11                        Free           David Gerrero    David Gerrero    David Gerrero    David Gerrero    David Gerrero
12
13
14
...

What algorithm would you apply for the conversion?

I am trying to think of a proper way of doing it.

Thank you very much.
 
Last edited:
I was able to program Excel using the old method, but not VBA.

Anyway, you can take min and max to get min/max class room and date. It won;t work for "120A" or "conference" though.
That would get you your room and date table, anyway.

Then index through. I believe you can convert dates to numbers.

Finally clean up, by deleting rooms (rows) and dates (columns) that have no entries.

You might make a sanity check before proceeding.

The program might be faster, if you used pointers to the names and not the names. The names being on a separate sheet.
I've used that trick a lot in programming.

Just ideas.
 
Just create the destination table, init it wih "Free". Then enumerate your data filling the cells of your destination table as appropriate. You can also check if the cell you're about to fill is not "Free".
 
Thank you very much!

I appreciate your help KISS and NorthGuy :)

I have a question please.

I'm writing all the result into a CSV file, and open it with Excel.

Do you know how I could simulate an ALT+ENTER in the CSV File, in order to write 2 lines into a single Cell?

I google'd it, and tried different approaches, but failed to do so.

I'm writing C++.

Thank you!
 
Quotes around the element should work even if you have line break (0x0a 0x0d) inside.

If you have any doubts how CSV file should look like, create what you want in Excel, export is as a CSV and look at the CSV.
 
C++, definitely making things harder for yourself. Scripting languages are perfect for string manipulation, like Python or Tcl or something like that.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top