DEV Community

brendan for Kite

Posted on • Updated on • Originally published at kite.com

Using the Python Write to File Function

Python Write to File

How can developers and clients benefit from data being in a file format when there are so many other options out there? Why not just use a simple HTML page with AJAX requests and tables to display the data? In this blog post, let me show you why using Python to construct files is productive way of of creating and filling them with data. We will go over a few APIs to populate our files with data, and learn how to use the Requests HTTP library to fetch data. In this post, we'll be using Python 3 and its toolkit. Let’s get started!

You can easily access the code from this article in Kite' github repository.

Setting Objectives

Our first step is to set some objectives for our files.

  • First, we want some inspiration: to do that, we’re going to form a request to a famous quotes API using the Requests module in Python.
  • Second, we want to make sure our investments in the stock market are looking solid. We'll use IEXFinance Python wrapper around the Investors Exchange Developer API.
  • Third, we also want to make sure our cryptocurrencies are staying green as well. We'll fetch data with the Requests module from the Coinbase API to check on our digital assets.
  • Lastly, we'll take all this fetched data and write to files that correspond to each time we run the script and have one accumulative file. All of our files will be in CSV format.

I’m assuming that we’ll utilize the functionality of spreadsheet software to graph the data stored in the files. Let's dive into how the Requests HTTP library works, and get our quotes!

Read more on the Kite blog!

Top comments (0)