Python_User Wrote:I can't find the variable parts
defined in the code anyway...
parts is an attribute pathlib that Larz60+ use here.That Pylint complain about can you just ignore,as it's not error just that Pylint struggle whit pathlib.
Also is not necessary to split it up parts as done here,can just read
filename
from tkinter.filedialog import askopenfilename from pathlib import Path import csv def get_filename(): filename = Path(askopenfilename(filetypes=[("CSV files", "*.csv")])) return filename def read_csv_file(filename): # parts = list(filename.parts) with open(filename) as fp: crdr = csv.reader(fp, delimiter=',') for row in crdr: print(row) if __name__ == '__main__': read_csv_file(get_filename())
Output:['name', 'origin', 'dest']
['xxx', 'uk', 'france']
['yyyy', 'norway', 'finland']
['zzzz', 'denmark', 'canada']