简体   繁体   中英

canot import csv file in Python

Greeting fellow coders: Im trying to code a game inventory witch can import from a csv file but i get the error:

IndentationError: unindent does not match any outer indentation level

this is the code of my func.

def import_inventory(inventory, filename):
  file = open(filename)
  csvreader = csv.reader(file)
  
  for i in csvreader:
      add_to_inventory(inventory,csvreader)
   
   print(filename, " imported")
   file.close()
   return inventory

Happy for any help i get!

Your python code is not indented correctly. The last 3 lines of your code seem to have one extra space than the other lines. Or the the other way round and the first 3 lines inside your function have one space less:) Fixing either should help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM