Browse Source

Table

pull/44/head
Jure Šorn 5 years ago
parent
commit
f7a2fbcc5a
2 changed files with 6 additions and 8 deletions
  1. 7
      README.md
  2. 7
      index.html

7
README.md

@ -2271,13 +2271,12 @@ Table
#### Prints a CSV file as an ASCII table:
```python
# $ pip3 install tabulate
from tabulate import tabulate
import csv
import csv, tabulate
with open(<filename>, encoding='utf-8', newline='') as file:
rows = csv.reader(file)
header = [a.title() for a in next(rows)]
table = tabulate(rows, header)
print(table)
table = tabulate.tabulate(rows, header)
print(table)
```

7
index.html

@ -1958,13 +1958,12 @@ pyplot.show() <span class="hljs-comment"># Displays figure.</
pyplot.clf() <span class="hljs-comment"># Clears figure.</span>
</code></pre>
<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>
<span class="hljs-keyword">from</span> tabulate <span class="hljs-keyword">import</span> tabulate
<span class="hljs-keyword">import</span> csv
<span class="hljs-keyword">import</span> csv, tabulate
<span class="hljs-keyword">with</span> open(&lt;filename&gt;, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file:
rows = csv.reader(file)
header = [a.title() <span class="hljs-keyword">for</span> a <span class="hljs-keyword">in</span> next(rows)]
table = tabulate(rows, header)
print(table)
table = tabulate.tabulate(rows, header)
print(table)
</code></pre></div></div>

Loading…
Cancel
Save