Tabulate

Introduction

The Python tabulate module provides just one function, tabulate. It takes in a list of lists or another tabular data type, and outputs a formatted plain-text table.

Note: tabulate only works with small tables. If you need large tables you must use another method to create tables.

Project #1a

Create a "simple" table sorted by last name. The table must containing the following columns:

Use the column names without underscores in the table header.

If the data is to big for the tabulate module, use 20 (or less) of the data rows.

CVS Test Data For This Project

Project #1b

Same as project #1a.

Create an "grid" table. Use the same columns except add first name, phone number, zip code and state.

Project #1c

Same as project #1b.

Sort the data by states, within each state by zip code, and within each zip code by last name. (See code snippets.)

project #2

Create an interactive program. Let the user

project #3

Can you output these tables as HTML files? (Hint: use <pre> HTML tag and a monospace font.)

project #4

Repeat Project #1c, but use all of the CSV data. (i.e. Format the data yourself.)

For large tables, format the data yourself.

Hint

  1. use a monospace font (if possible)
  2. "screen scrape" the data into a CSV text file
  3. read the file
    1. convert the CSV test data to lists
    2. strip the data of interest into separate lists
    3. use separate lists to create tables

Install Tabulate Module

pip install tabulate OR python -m pip install tabulate

Links

tabulate 0.9.0

Python tabulate module: How to Easily Create Tables in Python?

CSV File Reading and Writing