Commit 03b6d8bf authored by Simon Pintarelli's avatar Simon Pintarelli

read only First, Last Name and Number.

- use the columns given in the student list on export, remove hardcoded names
parent 617e51a7
......@@ -54,7 +54,10 @@ def extract_columns(args):
"""
try:
edoz_data = pa.read_csv(args.src, sep='\t', encoding='ISO-8859-1')
edoz_data = pa.read_csv(args.src,
sep=None,
encoding='ISO-8859-1',
engine='python')
except:
raise Exception('Could not read from csv-file ' + str(args.src) +
str('\nCheck that the file exists and is ISO-8859-1 encoded'))
......@@ -67,8 +70,8 @@ def extract_columns(args):
# assert(all([(i in header_de or i in header_en) for i in edoz_data.columns]))
# new_col_names = [translation[c] for c in edoz_data.columns]
# edoz_data.columns = new_col_names
raise Exception('Error: use the english version of edoz to export the student list, \n \
e.g. click on _English_ during login. ')
raise Exception('Use the english version of edoz to export the student list. \n \
E.g. click on _English_ during login.')
elif 'Last Name' in edoz_data:
# there is a tab past the last column => pandas reads an additional empty
# column (filled with nan) get rid of this additional column
......@@ -76,7 +79,7 @@ def extract_columns(args):
else:
raise Exception(
'Something with the column-headers is wrong (expected to find Last Name). Check your input file %s.'
% fname)
% args.src)
grade_columns = edoz_data[selected_columns].copy()
for i in range(1,5):
......
# coding: utf-8
import pandas as pa
data = pa.read_csv('___grades-template.txt', sep='\t', encoding='ISO-8859-1')
grades = pa.read_csv('grades-out.csv', sep=',', encoding='ISO-8859-1')
tmp = grades[['Number', 'Grade']]
out = pa.merge(data, tmp, on=('Number'))
out = out[['Id', 'Last Name', 'First Name', 'Number', 'Administration Office',
'Direction', 'Rep.', 'Grade_y', '+ / - (Grade Trend)',
'* (dropout/no show)', 'Checksum']]
out.columns = ['Id', 'Last Name', 'First Name', 'Number', 'Administration Office',
'Direction', 'Rep.', 'Grade', '+ / - (Grade Trend)',
'* (dropout/no show)', 'Checksum']
data = pa.read_csv('___grades-template.txt',
sep=None,
engine='python',
encoding='ISO-8859-1')
grades = pa.read_csv('grades-out.csv',
encoding='ISO-8859-1',
sep=',')
sel_grades = grades[['Number', 'Grade']]
out = pa.merge(data.drop('Grade', 1),
sel_grades,
on=('Number'))
out = out[data.columns]
out.to_csv('edoz-final.txt', sep='\t', encoding='ISO-8859-1', index=False)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment