Beispiel #1
0
########################################################################
### Parse the titles.csv file, and import data to the MySQL database ###
########################################################################

import Database as DB
import Parse as Parse
import csv

# Parse data from csv file

filename = '../CSV/titles_rem.csv'
f = open(filename, 'rU')
f.seek(0)

fields = ['id', 'title', 'translator', 'synopsis', 'note_id', 'series_id', 'series_nb', 'story_length', 'story_type', 'parent', 'language_id', 'title_graphic']
reader = csv.DictReader(f, dialect='excel-tab', fieldnames=fields)

data = []
for row in reader:

    title_graphic = Parse.booleanize2(row['title_graphic'])
    data.append(
		(row['id'], row['title'], row['translator'], row['synopsis'], 
		 row['note_id'], row['series_id'], row['series_nb'], 
		 row['story_length'], row['story_type'], row['parent'], 
		 row['language_id'], title_graphic)
	       ) 

Parse.writeRows(data, 'titles')
Beispiel #2
0
#!/usr/bin/env python
# coding=utf-8

__author__ = 'Alexandre Connat'

########################################################################
### Parse the awards.csv file, and import data to the MySQL database ###
########################################################################

import Database as DB
import Parse as Parse
import csv

# Parse data from csv file

filename = '../CSV/awards_rem.csv'
f = open(filename, 'rU')
f.seek(0)

fields = ['id', 'title', 'date', 'type_code', 'type_id', 'category_id', 'note_id']
reader = csv.DictReader(f, dialect='excel-tab', fieldnames=fields)

#here we omit type code because that we want as end input of load data
data = []
for row in reader:
    data.append( (row['id'], row['title'], row['date'], row['type_id'], row['category_id'], row['note_id']) )

Parse.writeRows(data, 'awards')