def load_file(filename): with open(filename, 'r') as fin: reader = csv.DictReader(fin) # creates Ordered Dict purchases = [] for row in reader: # print(type(row), row) # print("Bed count: {}".format(row['beds'])) p = Purchase.create_from_dict( row) # creating Purchase object from dict # p = Purchase( # lookup['street'], # lookup['city'], # lookup['zip'], # lookup['state'], # int(lookup['beds']), # int(lookup['baths']), # int(lookup['sq__ft']), # lookup['type'], # lookup['sale_date'], # float(lookup['price']), # float(lookup['latitude']), # float(lookup['longitude'])) purchases.append(p) return purchases
def load_file(file): with open(file, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: purchases.append(Purchase.create_from_dict(row)) return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): with open(filename, "r") as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_data(filename): with open(filename, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) # print(purchases[0].__dict__) # use purchases[0].__dict__ to use internal dictionary and look at the data return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: # print(type(row), row) # print("Bed count: {}, type: {}".format(row['beds'], type(row['beds']))) p = Purchase.create_dict(row) purchases.append(p) return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: #print(type(row), row) p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] # create an empty list for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file( filename): # this function used to load and read the data from file with open(filename, 'r', encoding='utf-8') as fin: # with open(filename, 'r') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): # with open(filename, 'r', encoding='utf8') as fin: with open(filename, 'r') as fin: reader = csv.DictReader(fin, delimiter=',') purchases = [] for row in reader: # print(row) # print("Bed count: {}".format(row['beds'])) p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): with open(filename, 'r') as fin: reader = csv.DictReader(fin) purchases = [] # header = fin.readline().strip() # reader = csv.reader(fin, delimiter=',') for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: # print(type(row), row) # print('bed count: {}'.format(row['beds'])) p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: # Row will be collections.OrderedDict in Python 3.6 and above reader = csv.DictReader(fin) purchases = [] for row in reader: # print(type(row), row) # print("Bed count: {}".format(row['beds'])) p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): with open(filename, 'r', encoding="ISO-8859-1") as fin: # changed for python 2.7 reader = csv.DictReader(fin) purchases = [] for row in reader: #print("Bed count: {}".format(row['beds'])) p = Purchase.create_from_dict(row) purchases.append(p) return purchases
def load_file(filename): # with open(filename, 'r', encoding='utf-8') as fin: encoding no good with py 2 with open(filename, 'r') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) #print(purchases[0].__dict__) return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) # header = fin.readline().strip() # reader = csv.reader(fin) # for row in reader: # print(row) return purchases
def load_file(filename: str): """ brief: reads in a csv file provided by p/ filename using a csv.DictReader return: a list of Purchase class objects param: filename - the full system path of a csv file """ purchases = [] with open(filename, 'r', encoding='utf-8', errors='ignore') as fin: reader = csv.DictReader(fin) for row in reader: purchase = Purchase.create_from_dict(row) purchases.append(purchase) return purchases
def load_file(filename): with open(filename, "r", encoding="utf-8") as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: # print(type(row), row) # print("Bed count: {}".format(row["beds"])) p = Purchase.create_from_dict(row) purchases.append(p) # This way you need to use numeric indexes! # header = fin.readline().strip() # reader = csv.reader(fin) # for row in reader: # print(type(row), row) # beds = row[4] return purchases
def load_file(filename): with open(filename, 'r', encoding='utf-8') as fin: #with open(filename, 'r') as fin: reader = csv.DictReader(fin) # load file input purchases = [] # create a list for row in reader: # loop and do test - not on this item # print(type(row), row) # print("Bed count: {}, type: {}".format(row['beds'], type(row['beds']))) # print(row) # print('----------------------------') p = Purchase.create_from_dict(row) # print(p.__dict__) purchases.append(p) # print(purchases[0].__dict__) return purchases
def load_file(file_name): with open(file_name, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: # print('Type: {} Row: {}'.format(type(row), row)) # print('Beds #: {}'.format(row['Beds'])) p = Purchase.create_from_dict(row) purchases.append(p) print(purchases[0].__dict__) # header = fin.readline().strip() # reader = csv.reader(fin, delimiter=',') # for row in reader: # print('Row: {}'.format(row)) return purchases
def load_file(data_file): # with open(data_file, 'r', encoding='utf-8') as fin: with open(data_file, 'r') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: p = Purchase.create_from_dict(row) purchases.append(p) # print(purchases[0].__dict__) # # Header Row # header = fin.readline().strip() # # Data Rows # reader = csv.reader(fin, delimiter=',') # for row in reader: # print(row) # print("Bed count: {}".format(row['beds'])) return purchases
def load_data(datafile): print('Loading CSV real estate data from {} ..... '.format(datafile), end=' ') # python 2.7 does not support encoding # open would have to be updated to # with open(datafile, 'r') as fin: with open(datafile, 'r', encoding='utf-8') as fin: reader = csv.DictReader(fin) purchases = [] for row in reader: #print("Bed count: {}".format(row['beds'])) p = Purchase.create_from_dict(row) purchases.append(p) print('Done') return purchases