This lesson introduces Comma Separated Values(CSV) files, a plain text file format commonly used for input/output of programs. In this video, you learned that CSV files:
- Are a common input/output file type for programs
- Are plain text files that contain no non-printable characters
- Easy to work with programmatically
- Contain different sections which are separated by a comma or other delimeter
sweir12525 on Aug. 17, 2020
I am having a very difficult time trying to import a cvs file into whatever interpreter you are using in this tutorial
I put a file on my desktop and tried to import it and read it, as follows:
import csv
with open(‘C:\Desktop\Phyton_Projects\instructor.cvs’) as cvs_file: csv_reader = csv.reader(csv_file, delimiter=’,’) line_count = 0 for row in csv_reader: if line_count ==0: print(f’column names are {“,”.join (row)}’) line_count +=1 else: print(f’\t{row[1]} taught course {row[0]}, at host location {row[4]}’)
I am getting an error saying in Thorny saying I need a r prefix but I don’t know where to put it. Can you help?