diff --git a/README.md b/README.md index f9d3e0b..742c152 100644 --- a/README.md +++ b/README.md @@ -2397,6 +2397,7 @@ Plot ```python # $ pip3 install matplotlib import matplotlib.pyplot as plt + plt.plot/bar/scatter(x_data, y_data [, label=]) # Or: plt.plot(y_data) plt.legend() # Adds a legend. plt.savefig() # Saves the figure. @@ -2412,10 +2413,8 @@ Table # $ pip3 install tabulate import csv, tabulate with open('test.csv', encoding='utf-8', newline='') as file: - rows = csv.reader(file) - header = next(rows) - table = tabulate.tabulate(rows, header) -print(table) + rows = list(csv.reader(file)) +print(tabulate.tabulate(rows, headers='firstrow')) ``` diff --git a/index.html b/index.html index aa1f96e..a3ddbf3 100644 --- a/index.html +++ b/index.html @@ -1977,6 +1977,7 @@ Processing: 100%|████████████████████| 3

#Plot

# $ pip3 install matplotlib
 import matplotlib.pyplot as plt
+
 plt.plot/bar/scatter(x_data, y_data [, label=<str>])  # Or: plt.plot(y_data)
 plt.legend()                                          # Adds a legend.
 plt.savefig(<path>)                                   # Saves the figure.
@@ -1987,10 +1988,8 @@ plt.clf()                                             

#Table

Prints a CSV file as an ASCII table:

# $ pip3 install tabulate
 import csv, tabulate
 with open('test.csv', encoding='utf-8', newline='') as file:
-    rows   = csv.reader(file)
-    header = next(rows)
-    table  = tabulate.tabulate(rows, header)
-print(table)
+    rows = list(csv.reader(file))
+print(tabulate.tabulate(rows, headers='firstrow'))