Browse Source

Table

pull/36/head
Jure Šorn 5 years ago
parent
commit
e9a017098a
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -1905,7 +1905,7 @@ Table
# $ pip3 install tabulate
from tabulate import tabulate
import csv
with open(<filename>, encoding='utf-8') as file:
with open(<filename>, encoding='utf-8', newline='') as file:
lines = csv.reader(file, delimiter=';')
headers = [header.title() for header in next(lines)]
table = tabulate(lines, headers)

2
index.html

@ -1613,7 +1613,7 @@ pyplot.show()
<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">with</span> open(&lt;filename&gt;, encoding=<span class="hljs-string">'utf-8'</span>) <span class="hljs-keyword">as</span> file:
<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:
lines = csv.reader(file, delimiter=<span class="hljs-string">';'</span>)
headers = [header.title() <span class="hljs-keyword">for</span> header <span class="hljs-keyword">in</span> next(lines)]
table = tabulate(lines, headers)

Loading…
Cancel
Save