Skip to content

Commit 4ace877

Browse files
committed
Table
1 parent e1cb5e7 commit 4ace877

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,7 @@ Plot
23972397
```python
23982398
# $ pip3 install matplotlib
23992399
import matplotlib.pyplot as plt
2400+
24002401
plt.plot/bar/scatter(x_data, y_data [, label=<str>]) # Or: plt.plot(y_data)
24012402
plt.legend() # Adds a legend.
24022403
plt.savefig(<path>) # Saves the figure.
@@ -2412,10 +2413,8 @@ Table
24122413
# $ pip3 install tabulate
24132414
import csv, tabulate
24142415
with open('test.csv', encoding='utf-8', newline='') as file:
2415-
rows = csv.reader(file)
2416-
header = next(rows)
2417-
table = tabulate.tabulate(rows, header)
2418-
print(table)
2416+
rows = list(csv.reader(file))
2417+
print(tabulate.tabulate(rows, headers='firstrow'))
24192418
```
24202419

24212420

index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
19771977

19781978
<div><h2 id="plot"><a href="#plot" name="plot">#</a>Plot</h2><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install matplotlib</span>
19791979
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
1980+
19801981
plt.plot/bar/scatter(x_data, y_data [, label=&lt;str&gt;]) <span class="hljs-comment"># Or: plt.plot(y_data)</span>
19811982
plt.legend() <span class="hljs-comment"># Adds a legend.</span>
19821983
plt.savefig(&lt;path&gt;) <span class="hljs-comment"># Saves the figure.</span>
@@ -1987,10 +1988,8 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
19871988
<div><h2 id="table"><a href="#table" name="table">#</a>Table</h2><div><h4 id="printsacsvfileasanasciitable">Prints a CSV file as an ASCII table:</h4><pre><code class="python language-python hljs"><span class="hljs-comment"># $ pip3 install tabulate</span>
19881989
<span class="hljs-keyword">import</span> csv, tabulate
19891990
<span class="hljs-keyword">with</span> open(<span class="hljs-string">'test.csv'</span>, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file:
1990-
rows = csv.reader(file)
1991-
header = next(rows)
1992-
table = tabulate.tabulate(rows, header)
1993-
print(table)
1991+
rows = list(csv.reader(file))
1992+
print(tabulate.tabulate(rows, headers=<span class="hljs-string">'firstrow'</span>))
19941993
</code></pre></div></div>
19951994

19961995

0 commit comments

Comments
 (0)