Beispiel #1
0
def load_csv(self):
    # import codecs
    # reader = codecs.getreader('utf-8')
    reader = csv.reader(open('./data/base_ex_women.csv', 'r'))

    print(repr(reader))
    print(dir(reader))

    try:
        i = True
        while True:
            row = reader.next()
            row = [unicode(s, "utf-8") for s in row]
        # for row in reader.next():
            if i:
                i = False
                continue
            logging.error(row)

            c = Exercise()
            # row = map(str, row)
            row = row + ([''] * 5)
            logging.error(row)

            c.title = row[0]
            c.description = row[1]
            c.image_link = row[2]
            c.link_to = row[3]
            c.video_link = row[4]
            c.for_women = True

            c.save()
    except Exception, e:
        pass