Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

What Are CSV Files?

Give Feedback

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


Sample CSV Files (.zip)

643 bytes

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?

Geir Arne Hjelle RP Team on Aug. 17, 2020


Backslashes (\) have special meanings in Python (and many other programming languages) as escape sequences that allow you specify special characters. A couple of the most common examples are \n which represents a newline (enter) and \t which represent a tab character.

Unfortunately, backslashes are also used by file paths in Windows. Python is not able to interpret the path to your CSV file because of the backslashes being interpreted as special characters.

The easiest way to work around this is to tell Python that the path is something called a raw string (or r-string) by prefixing it with an r like Thonny suggests. You would do that by putting an r immediately in front of the opening quote when specifying the path:

with open(r'C:\Desktop\Phyton_Projects\instructor.cvs’) as cvs_file:

Become a Member to join the conversation.