Coder Social home page Coder Social logo

iampatterson / airtable-to-pandas-dataframe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gtalarico/pyairtable

7.0 1.0 2.0 6.58 MB

Python Airtable Client Wrapper

Home Page: http://airtable-python-wrapper.readthedocs.io/

License: MIT License

Python 98.39% Makefile 1.61%

airtable-to-pandas-dataframe's Introduction

Foreword.

This python wrapper for Airtable is a convenient bit of code. It is notably helpful if you are a single shingle person, such as myself. I like my clients to use Airtable, it is easy to use organize and share your data, especially by using Zapier.

For you to pull data from a specific file (in Airtable it is called a "Base"), and specific sheet/tab (in Airtable it is called a "View"), all you need to do is get the base key and API key from Airtable and plunk it in the code below. I am a Data Scientist, so much of what I do uses a particular format of a file called a "dataframe." A dataframe is a unique bucket that you put data into so that we can run magical code and get answers for our teachers, bosses, peers and customers.

The extra handy part of the code below is that the output from Airtable is chopped, sorted and stuffed into these dataframes in one smooth move. I was having a problem with the "environ.os" part of the code referenced in the master branch. Also, I found many people on Stack Overflow and Airtable forums that had the same problem I had, but with no resolution.

After much futzing around, I realized that I needed to "explicitly" reference the key for my code to work, so I thought I would post it below, just in case anyone else needed it. The problem manifests itself in a "key error" if you don't declare the API key globally before you run the code.

You will need to install the package (see below). And you are off to the races.

Here my quick snippet of code.

import os
from pprint import pprint
from airtable import airtable
import pandas as pd

# Connects you into your Airtable.
base_key = 'Paste your base_key between the quotes'
table_name = 'Paste the name of the view (i.e sheet) between the quotes'
airtable = airtable.Airtable(base_key, table_name, api_key='Paste your api key between the quotes')

# Downloads all your records into a dataframe.
records = airtable.get_all()
df = pd.DataFrame.from_records((r['fields'] for r in records))
print(df)

Airtable Python Wrapper

Build Status PyPI - Downloads Coverage Status Documentation Status

Airtable API Client Wrapper for Python

project-logo

Installing

pip install airtable-python-wrapper

Documentation

Full documentation here:

http://airtable-python-wrapper.readthedocs.io/

Usage Example

Below are some of the methods available in the wrapper.

For the full list and documentation visit the docs

You can see the wrapper in action in this Jupyter Notebook.

airtable = Airtable('baseKey', 'table_name')

airtable.get_all(view='MyView', maxRecords=20)

airtable.insert({'Name': 'Brian'})

airtable.search('Name', 'Tom')

airtable.update_by_field('Name', 'Tom', {'Phone': '1234-4445'})

airtable.delete_by_field('Name', 'Tom')

License

MIT

airtable-to-pandas-dataframe's People

Contributors

bpeterso2000 avatar dargueta avatar dependabot[bot] avatar gtalarico avatar iampatterson avatar lemonez avatar madindustries avatar maxko87 avatar yun-wang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

jceg galongoria

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.