1. 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.
    Dismiss Notice

Programming question

Discussion in 'Computers and Networks' started by electroRF, Nov 13, 2015.

  1. electroRF

    electroRF Member

    Joined:
    Jun 23, 2012
    Messages:
    689
    Likes:
    9
    Location:
    Portugal
    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 (text):

    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 (text):

                           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: Nov 13, 2015
  2. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,887
    Likes:
    1,091
    ONLINE
    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.
     
  3. NorthGuy

    NorthGuy Well-Known Member

    Joined:
    Sep 8, 2013
    Messages:
    1,218
    Likes:
    206
    Location:
    Northern Canada
    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".
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. electroRF

    electroRF Member

    Joined:
    Jun 23, 2012
    Messages:
    689
    Likes:
    9
    Location:
    Portugal

    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!
     
  6. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,887
    Likes:
    1,091
    ONLINE
    Insert a Chr(10) or line feed for alt enter.

    Still don't know why your not doing it in Excel?
     
  7. NorthGuy

    NorthGuy Well-Known Member

    Joined:
    Sep 8, 2013
    Messages:
    1,218
    Likes:
    206
    Location:
    Northern Canada
    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.
     
  8. Cicero

    Cicero Active Member

    Joined:
    Nov 21, 2014
    Messages:
    334
    Likes:
    36
    Location:
    UK
    C++, definitely making things harder for yourself. Scripting languages are perfect for string manipulation, like Python or Tcl or something like that.
     

Share This Page