save.py 581 Bytes
import csv
import pymongo

conn = pymongo.MongoClient("localhost")
db = conn.test
MOVIE = db.movie
MOVIE.delete_many({}) #reset

csvfile = open('C:\\Users\\ghdms\\2014104137\\소스코드\\kobis.csv', mode='r')
reader = list(csv.reader(csvfile))
for row in reader:
	name = row[1]
	for i in range(2, 6):
		row[i] = row[i].replace(",", "")
	sales, audiences, screens, plays = int(row[2]), int(row[3]), int(row[4]), int(row[5])
	print(name, sales, audiences, screens, plays)
	MOVIE.insert_one({"name": name, "sales": sales, "audiences": audiences, "screens": screens, "plays": plays})