Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introduction to Data Visualization with Matplotlib Chart Toppers Our Data Set - Flower Power

Arturo Acosta
Arturo Acosta
7,638 Points

I managed to import the csv but still don't know how it works

In this line: with open(input_file, 'r')..... what does that 'r' do and please explain what are the parameters, does it have to do with the folder or directory you're looking in or something?. I couldn't find an answer myself for this one sorry.

1 Answer

Steven Parker
Steven Parker
231,198 Points

The "open" function takes two arguments, the filename and the mode. The "mode" is a code indicating what you will be doing with the file, and "r" means it will only be read.

For more details, see the online Python documentation for Reading and Writing Files.