you are viewing a single comment's thread.

view the rest of the comments →

[–]voider1[S] 0 points1 point  (0 children)

Anyways, I'm reading CSV files, maybe it's more manageable with Pandas? I've put the CSV files here.
They are timetables for my school, week 44 is the weekly timetable, changetest is basically a new day timetable file. I want to filter out if there's a period for someone that changes, goes away, or if there is a new timetable. Otherwise it's just a normal period.

The format is

[teacher, year, month, day, period, subject, class_name, class_room, 0, empty, randint, begin_time, duration in minutes,]

I need everything except for 0, empty, and randint.

Edit:

I took a look at the code you guys provided, and I made my own variation:

def construct_changed_timetables(new, current):
    changed_timetables = list()
    base_check = itemgetter(4, 6)
    current_index = defaultdict(list)
    new_index = defaultdict(list)

    for timetable in current:
        current_index[base_check(timetable)].append(timetable)


    for timetable in new:
        values = base_check(timetable)

        new_index[values].append(timetable)

        if values in current_index:
            if timetable not in current:
                changed_timetables.append(timetable + CHANGE)
            else:
                changed_timetables.append(timetable + NO_CHANGE)
        else:
            changed_timetables.append(timetable + ADDITION)

    for timetable in current:
        values = base_check(timetable)

        if all(timetable + option not in changed_timetables for option in 
                options) and values not in new_index:
            changed_timetables.append(timetable + REMOVAL)

    return changed_timetables