save_kobis.py
332 Bytes
import csv
import pymongo
conn = pymongo.MongoClient("localhost")
db = conn.test
MOVIE = db.movie
MOVIE.delete_many({}) #reset
csvfile = open('kobis2.csv', mode='r')
reader = list(csv.reader(csvfile))
for row in reader:
num = int(row[1].replace(",", ""))
print(num)
MOVIE.insert_one({"name": row[0], "audience": num})