示例#1
0
def summary_table_read(file, fieldnames, rows):
    with open(file, "rb") as csvfile:
        reader = unicodecsv.DictReader(csvfile, fieldnames)
        for row in reader:
            registration_number_handler(row)
            period_handler(row)
            row.pop(None, None)
            rows.append(row)
示例#2
0
def students_table_write(file, fieldnames, rows, db, exclusions):
    with open(file, 'w') as csvfile:
        writer = unicodecsv.DictWriter(
            csvfile, fieldnames)
        writer.writeheader()
        for row in rows:
            registration_number_handler(row)
            if row['registration_number'] in exclusions[db]['STUDENTS']:
                continue
            if row['registration_number'] in exclusions['DUPLICATES']['STUDENTS']:
                continue
            #or else
            writer.writerow(row)
 def _assign_advisors(self):
     files = ['academic_advisors1.csv', 'academic_advisors2.csv']
     for file in files:
         with open(self.FILES_LOCATION + file, 'rb') as csvfile:
             reader = unicodecsv.DictReader(
                 csvfile, fieldnames=['registration_number',
                                      'student_name', 'advisor'])
             for row in reader:
                 registration_number_handler(row)
                 if self.verbosity > 1:
                         print("I'll now process {}, {}"
                               .format(row['registration_number'],
                                       row['student_name']))
                 student = Student.objects.get(
                     registration_number=row['registration_number']
                 )
                 student.advisor = row['advisor']
                 student.save()