Flat Data
Flat explores how to make it easy to work with data in git and GitHub. It builds on the “git scraping” approach pioneered by Simon Willison to offer a simple pattern for bringing working datasets into your repositories and versioning them, because developing against local datasets is faster and easier than working with data over the wire.
- Purpose
- Bring working sets of data to your repositories
- First published
- Stage
- Product, archived Open source
Flat Data eschews the complexity of many tools in the data/ETL space in favor of something simple and flexible enough for many workloads, but which requires no user-maintained infrastructure. While Flat has a ton of utility for developers, we want to make it easier for scientists, journalists, and other developer-adjacent audiences to develop lightweight, data-driven apps.
The Flat Data project incorporates three different pieces:
Flat is an experiment from the Developer Experience team in GitHub Next and is not an official GitHub product. We are publishing it (as well as all documentation and examples) under the terms of the MIT license
How to use Flat Data
Currently, Flat knows how to fetch data from two kinds of sources: any HTTP endpoint, or a SQL query against a supported datastore. Let’s start with the simpler of the two, an HTTP fetch! 1We jump right into how to use Flat Data, but feel free to click to skip down to why we built Flat Data
To get started with Flat Data, all you need is an endpoint or file that you want to download into a GitHub repository. In this case, we’ll be fetching the current Bitcoin price from this link every five minutes and storing that data in a GitHub repository. The complete example with a detailed tutorial can be found here.
Part I: Get data into your GitHub repository
We hope you’re already starting to see how the Flat Action can be useful. It allows you to download any kind of data (JSON, CSV, images, text files, zip folders, etc.) into your repositories at a repeatable schedule. As long as what you’re fetching has a URL, it can be downloaded into a GitHub repo.
At this point you’ve used Flat Data to get data on a schedule and keep it updated into your repo. Congrats!
But Flat Data can do a bit more. Read the optional parts II and III to see how you can add an extra step to process and view your data in more advanced ways.
Part II: Make the data your own Optional
What if you want to process or change the data in some way before it gets added to your repository? We’ve built in a way for you to run these types of tasks using the postprocess parameter in the Action. Let’s take a look at how to do that.
Part III: Visualizing our data for easy sharing Optional
Now that we have our data, what can we do with it? There are tons of options (throw it in a database, create a dashboard that uses it), but we just want to visualize and share it in a simple way.
For that we built Flat Viewer, a simple tool for browsing tabular CSV and non-nested JSON files from public GitHub repositories. The hosted viewer is unavailable. You can still explore the original boy band dataset on GitHub from The Pudding or run Flat Viewer locally.
Flat Viewer’s Commits dropdown highlights new, modified, and deleted lines after each run of the Flat Action.
Examples
As we saw in our walkthrough, the basics are very simple. You can get a Flat Action up and running in a few minutes. But Flat Data can be very powerful!
Here are a few examples for your reference, and to show the breadth of what Flat Data can help you with. Even more examples can be found here.