Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Python to get a CSV output for the following example
    primarykey
    data
    text
    <p>I'm back again with my ongoing saga of Student-Project Allocation questions. Thanks to <a href="https://stackoverflow.com/users/252697/moron">Moron</a> (who does not match his namesake) I've got a bit of direction for an evaluation portion of my project. </p> <p>Going with the idea of the Assignment Problem and Hungarian Algorithm I would like to express my data in the form of a .csv file which would end up looking like this in spreadsheet form. This is based on the structure I saw <a href="http://en.wikipedia.org/wiki/Hungarian_algorithm" rel="nofollow noreferrer">here</a>. </p> <pre><code>| | Project 1 | Project 2 | Project 3 | |----------|-----------|-----------|-----------| |Student1 | | 2 | 1 | |----------|-----------|-----------|-----------| |Student2 | 1 | 2 | 3 | |----------|-----------|-----------|-----------| |Student3 | 1 | 3 | 2 | |----------|-----------|-----------|-----------| </code></pre> <p>To make it less cryptic: the rows are the Students/Agents and the columns represent Projects/Task. Obviously ONE project can be assigned to ONE student. That, in short, is what my project is about. The fields represent the preference weights the students have placed upon the projects (ranging from 1 to 10). If blank, that student does not want that project and there's no chance of him/her being assigned such.</p> <p>Anyway, my data is stored within dictionaries. Specifically the students and projects dictionaries such that: </p> <pre><code>students[student_id] = Student(student_id, student_name, alloc_proj, alloc_proj_rank, preferences) where preferences is in the form of a dictionary such that preferences[rank] = {project_id} </code></pre> <p>and </p> <pre><code>projects[project_id] = Project(project_id, project_name) </code></pre> <p>I'm aware that <code>sorted(students.keys())</code> will give me a sorted list of all the student IDs which will populate the row labels and <code>sorted(projects.keys())</code> will give me the list I need to populate the column labels. Thus for each student, I'd go into their preferences dictionary and match the applicable projects to ranks. I can do that much. </p> <p>Where I'm failing is understanding how to create a .csv file. Any help, pointers or good tutorials will be highly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload