コード例 #1
0
ファイル: importer.py プロジェクト: lukin0110/website-sintjan
def importNews(out):
    #file = open('import/nieuws.yml')
    #map = yaml.load(file)
    #file.close()

    csvReader = csv.reader(open('import/nieuws.csv'), delimiter=';')
    
    for entry in csvReader:
        out.write(",".join(entry) + "\n")
        
        news = News()
        colnum = 0
        
        for col in entry:
            #out.write(str(colnum) + "-" + col + ",")
            
            if colnum == 1:
                news.name = unicode(col, errors='ignore')
            elif colnum == 2:
                news.email = unicode(col, errors='ignore')
            elif colnum == 3:
                news.title = unicode(col, errors='ignore')
            elif colnum == 4:
                news.date = newsParseDate(out, col)
            elif colnum == 5:
                news.msg = unicode(col, errors='ignore')
            elif colnum == 8:
                news.visible = util.parseBool(col)
            
            colnum += 1
            
        # store it!!!
        if news.msg != "" and news.msg != None and news.name != "" and news.name != None and news.title != "" and news.title != None:
            news.put()