def loadBrokerageToDB(filePath): with open(filePath, 'rU') as f: db = DBController() reader = csv.reader(f) for i, line in enumerate(reader): if i == 0: continue line = [word.strip() for word in line] brokerageDict = {'_id' : line[1], 'name' : line[0], 'code' : line[2]} db.saveBrokerage(brokerageDict)