I cant figure out why this isnt working and just throwing me an error. I tried to move some things areounf and its still not working. It has to be something about it not reading to the list or something like that.
from Country import Country import csv class CountryIRSystem: def __init__(self): self.__list_countries =  def search_name (self, country_name): for country in self.__list_countries: if country.country_name == country_name: return country_name return None def create_info(self, country_data): with open(country_data, "r") as csvfile: csvreader = csv.reader(csvfile) for line in csvreader: line = line.strip("\n") words = line.split() country = Country() country.country_name = words country.country_code = words country.acc_to_clean_fuel = words country.acc_to_elec = words country.annual_freshwater_withdrawl = words country.armed_forces_tot = words country.expense_gdp = words self.__list_countries.append(country)
for line in csvreader: line = line.strip("\n") words = line.split()
csvreader returns a list of field values, not a plain line of text.
So you can just do this instead:
for words in csvreader: ...