Not so flat any more
You can explore your current working directory natively in Python using the library os
, which consists of miscellaneous operating system interfaces.
The first line of the following code imports the library os
, the second line stores the name of the current directory in a string called wd
and the third outputs the contents of the directory in a list to the shell.
import os
wd = os.getcwd()
os.listdir(wd)
Run this code in the shell and answer the following questions. Ignore the files that begin with .
.
Check out the contents of your current directory and answer the following questions: (1) which file is in your directory and NOT an example of a flat file; (2) why is it not a flat file?
This exercise is part of the course
Introduction to Importing Data in Python
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
