From 62fbd5dddee2be8b9910af30564e821dd8dc5bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 18 Nov 2018 23:37:28 +0100 Subject: [PATCH] Tabulate --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1861dda..1b38410 100644 --- a/README.md +++ b/README.md @@ -601,7 +601,7 @@ SQLite ------ ```python import sqlite3 -db = sqlite3.connect(filename) +db = sqlite3.connect() ``` ### Read @@ -893,6 +893,18 @@ reader(adder(printer())) Libraries ========= +Terminal Table +-------------- +```python +# $ pip3 install tabulate +import csv +from tabulate import tabulate +with open(, newline='') as csv_file: + reader = csv.reader(csv_file, delimiter=';') + headers = [a.title() for a in next(reader)] + print(tabulate(reader, headers)) +``` + Plot ---- ```python @@ -900,7 +912,7 @@ Plot from matplotlib import pyplot pyplot.plot( [, ]) pyplot.show() -pyplot.savefig(filename, transparent=True) +pyplot.savefig(, transparent=True) ``` UrlLib @@ -1031,7 +1043,7 @@ Audio ```python import wave, struct frames = [struct.pack('%dh'%(1), int((a-0.5)*60000)) for a in ] -wf = wave.open(filename, 'wb') +wf = wave.open(, 'wb') wf.setnchannels(1) wf.setsampwidth(4) wf.setframerate(44100)