Changeset 2128 for WAeUP_SRP


Ignore:
Timestamp:
20 Aug 2007, 08:17:12 (17 years ago)
Author:
joachim
Message:

dumpStundents now uses csvwriter should do all formatting correct

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r2125 r2128  
    10511051        fields.append('state')
    10521052        headline = ','.join(fields)
    1053         open(export_file,"a").write(headline +'\n')
     1053        #open(export_file,"a").write(headline +'\n')
     1054        out = open(export_file,"wb")
     1055        out.write(headline +'\n')
     1056        out.close()
     1057        out = open(export_file,"a")
     1058        csv_writer = csv.DictWriter(out,fields,)
    10541059        format = '"%(' + ')s","%('.join(fields) + ')s"'
    10551060        students = self.students_catalog()
     
    10641069            d = self.getFormattedStudentEntry(student)
    10651070            d['state'],d['lga'] = formatLGA(d['lga'],voc = self.portal_vocabularies.local_gov_areas)
    1066             lines.append(format % d)
     1071            #lines.append(format % d)
     1072            lines.append(d)
    10671073            total += 1
    10681074            if total and not total % chunk or total == len(students):
    1069                 open(export_file,"a").write('\n'.join(lines) +'\n')
     1075                #open(export_file,"a").write('\n'.join(lines) +'\n')
     1076                csv_writer.writerows(lines)
    10701077                anz = len(lines)
    10711078                logger.info("wrote %(anz)d  total written %(total)d" % vars())
Note: See TracChangeset for help on using the changeset viewer.