Changeset 719 for WAeUP_SRP


Ignore:
Timestamp:
18 Oct 2006, 06:27:03 (18 years ago)
Author:
Henrik Bettermann
Message:

fixed csv format again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Academics.py

    r718 r719  
    2424i_home = Globals.INSTANCE_HOME
    2525
    26 def makeCertificateCode(code):
     26def makeCertificateCode(code): ###(
    2727    code = code.replace('.','')
    2828    code = code.replace('(','')
     
    3232    code = code.replace('_','')
    3333    return code
     34
     35###)
    3436
    3537class AcademicsFolder(CPSDocument): ###(
     
    105107                  "bank_code",
    106108                  )
    107         format = ' '.join(['%%(%s)s ' % fn for fn in fields])
     109        format = ','.join(['"%%(%s)s"' % fn for fn in fields])
    108110        for faculty in faculties:
    109111            processing = "processing %s" % format
     
    139141                  "faculty_code",
    140142                  )
    141         format = ' '.join(['%%(%s)s ' % fn for fn in fields])
     143        format = ','.join(['"%%(%s)s"' % fn for fn in fields])
    142144        try:
    143145            deps = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     
    146148            return
    147149        no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
    148         heading = ' '.join(['"%s"' % fn for fn in fields])
     150        heading = ','.join(['"%s"' % fn for fn in fields])
    149151        no_import.write('%s\n' % heading)
    150152        l = self.portal_catalog({'meta_type': "Faculty"})
     
    200202                  "session",
    201203                  )
    202         format = ' '.join(['%%(%s)s ' % fn for fn in fields])
     204        format = ','.join(['"%%(%s)s"' % fn for fn in fields])
    203205        try:
    204206            courses = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     
    207209            return
    208210        no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
    209         heading = ' '.join(['"%s"' % fn for fn in fields])
     211        heading = ','.join(['"%s"' % fn for fn in fields])
    210212        no_import.write('%s\n' % heading)
    211213        l = self.portal_catalog({'meta_type': "Faculty"})
     
    272274                  "admin_status",
    273275                  )
    274         format = ' '.join(['%%(%s)s ' % fn for fn in fields])
     276        format = ','.join(['"%%(%s)s"' % fn for fn in fields])
    275277        try:
    276278            courses = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     
    320322        if no_import_list:
    321323            no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
    322             heading = ' '.join(['"%s"' % fn for fn in fields])
     324            heading = ','.join(['"%s"' % fn for fn in fields])
    323325            no_import.write('%s\n' % heading)
    324326            for line in no_import_list:
     
    345347                  "core_or_elective",
    346348                  )
    347         format = ' '.join(['%%(%s)s ' % fn for fn in fields])
     349        format = ','.join(['"%%(%s)s"' % fn for fn in fields])
    348350        try:
    349351            cert_courses = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
     
    367369                logger.info(em)
    368370                #no_import_list.append(em)
    369                 no_import_list.append(format % cert_course + "CertificateCourse\n")
     371                no_import_list.append(format % cert_course + ',"Certificate"\n')
    370372                continue
    371373            certificate = certs[code]
     
    375377                logger.info(em)
    376378                #no_import_list.append(em)
    377                 no_import_list.append(format % cert_course + "Course\n")
     379                no_import_list.append(format % cert_course + ',"Course"\n')
    378380                continue
    379381            if depid not in d_ids:
     
    381383                logger.info(em)
    382384                #no_import_list.append(em)
    383                 no_import_list.append(format % cert_course + "Department\n")
     385                no_import_list.append(format % cert_course + ',"Department"\n')
    384386                continue
    385387            level = cert_course.get('level')
     
    395397                logger.info(msg)
    396398                #no_import_list.append(msg + "\n")
    397                 no_import_list.append(format % cert_course + "duplicate\n")
     399                no_import_list.append(format % cert_course + ',"duplicate"\n')
    398400                continue
    399401            l.invokeFactory('CertificateCourse',course_code)
     
    413415        if no_import_list:
    414416            no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
    415             heading = ' '.join(['"%s"' % fn for fn in fields])
     417            heading = ','.join(['"%s"' % fn for fn in fields])
    416418            no_import.write('%s\n' % heading)
    417419            for line in no_import_list:
Note: See TracChangeset for help on using the changeset viewer.