Reading Files
While databases such as MySQL and Postgres are popular and are widely used in many web applications, there is still a large amount of data that is stored and exchanged using text file formats. Popular formats like comma-separated values (CSV), JavaScript Object Notation (JSON), and plain text are used to store information such as weather data, traffic data, and sensor readings. You should take a look at the following exercise to read text from a file using Python.
Exercise 58: Reading a Text File Using Python
In this exercise, you will be downloading a sample data file online and reading data as the output:
- Open a new Jupyter Notebook.
- Now, copy the
text
file from the URL (https://packt.live/2MIHzhO), save it to a local folder aspg37431.txt
, and remember where it is located. - Upload the file to your Jupyter Notebook by clicking on the
Upload
button in the top-right corner. Select thepg37431.txt
file from your local folder, and then click on the...