# Lesson goal: Reading from a data file

Previous: Introduction to data files | Home | Next: Reading all data from a file (1)

In the last lesson, you learned how to open a file. Now, let's learn how to read in some data contained in the file.

To read data from a file, you can used the file_read function, that works like this:

# Now you try. Run the code and see if you can read the first line of data from the file sample.dat.

This code will not run! Fill in the file name in the file_open line, and what will you pass in to the file_read function?

If everything works, you should see a number appear on your screen, which is the first number in the file sample.dat. Dismiss.

Show a friend, family member, or teacher what you've done!