Skip to content

Commit f03f5b6

Browse files
committed
Paths, CSV
1 parent 1d552e4 commit f03f5b6

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
658658
<TD> = <D/DTn> - <D/DTn> # Returns the difference, ignoring time jumps.
659659
<TD> = <DTa> - <DTa> # Ignores time jumps if they share tzinfo object.
660660
<TD> = <TD> * <real> # Also: <TD> = abs(<TD>) and <TD> = <TD> ±% <TD>.
661-
<float> = <TD> / <TD> # How many weeks/years there are in TD. Also '//'.
661+
<float> = <TD> / <TD> # How many weeks/years there are in TD. Also //.
662662
```
663663

664664

@@ -1637,6 +1637,11 @@ from glob import glob
16371637
<bool> = path.isdir(<path>) # Or: <DirEntry/Path>.is_dir()
16381638
```
16391639

1640+
```python
1641+
<stat> = os.stat(<path>) # Or: <DirEntry/Path>.stat()
1642+
<real> = <stat>.st_mtime/st_size/# Modification time, size in bytes, …
1643+
```
1644+
16401645
### DirEntry
16411646
**Using scandir() instead of listdir() can significantly increase the performance of code that also needs file type information.**
16421647

@@ -1803,6 +1808,7 @@ import csv
18031808
<list> = next(<reader>) # Returns next row as a list of strings.
18041809
<list> = list(<reader>) # Returns a list of remaining rows.
18051810
```
1811+
* **For XML and binary Excel files (xlsx, xlsm and xlsb) use [Pandas](#dataframe-plot-encode-decode) library.**
18061812
* **File must be opened with a `'newline=""'` argument, or newlines embedded inside quoted fields will not be interpreted correctly!**
18071813

18081814
### Write

index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<body>
5656
<header>
57-
<aside>April 20, 2022</aside>
57+
<aside>May 2, 2022</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -585,7 +585,7 @@
585585
&lt;TD&gt; = &lt;D/DTn&gt; - &lt;D/DTn&gt; <span class="hljs-comment"># Returns the difference, ignoring time jumps.</span>
586586
&lt;TD&gt; = &lt;DTa&gt; - &lt;DTa&gt; <span class="hljs-comment"># Ignores time jumps if they share tzinfo object.</span>
587587
&lt;TD&gt; = &lt;TD&gt; * &lt;real&gt; <span class="hljs-comment"># Also: &lt;TD&gt; = abs(&lt;TD&gt;) and &lt;TD&gt; = &lt;TD&gt; ±% &lt;TD&gt;.</span>
588-
&lt;float&gt; = &lt;TD&gt; / &lt;TD&gt; <span class="hljs-comment"># How many weeks/years there are in TD. Also '//'.</span>
588+
&lt;float&gt; = &lt;TD&gt; / &lt;TD&gt; <span class="hljs-comment"># How many weeks/years there are in TD. Also //.</span>
589589
</code></pre></div>
590590

591591
<div><h2 id="arguments"><a href="#arguments" name="arguments">#</a>Arguments</h2><div><h3 id="insidefunctioncall">Inside Function Call</h3><pre><code class="python language-python hljs">&lt;function&gt;(&lt;positional_args&gt;) <span class="hljs-comment"># f(0, 0)</span>
@@ -1392,6 +1392,9 @@
13921392
&lt;bool&gt; = path.isfile(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;DirEntry/Path&gt;.is_file()</span>
13931393
&lt;bool&gt; = path.isdir(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;DirEntry/Path&gt;.is_dir()</span>
13941394
</code></pre>
1395+
<pre><code class="python language-python hljs">&lt;stat&gt; = os.stat(&lt;path&gt;) <span class="hljs-comment"># Or: &lt;DirEntry/Path&gt;.stat()</span>
1396+
&lt;real&gt; = &lt;stat&gt;.st_mtime/st_size/… <span class="hljs-comment"># Modification time, size in bytes, …</span>
1397+
</code></pre>
13951398
<div><h3 id="direntry">DirEntry</h3><p><strong>Using scandir() instead of listdir() can significantly increase the performance of code that also needs file type information.</strong></p><pre><code class="python language-python hljs">&lt;iter&gt; = scandir(path=<span class="hljs-string">'.'</span>) <span class="hljs-comment"># Returns DirEntry objects located at path.</span>
13961399
&lt;str&gt; = &lt;DirEntry&gt;.path <span class="hljs-comment"># Returns whole path as a string.</span>
13971400
&lt;str&gt; = &lt;DirEntry&gt;.name <span class="hljs-comment"># Returns final component as a string.</span>
@@ -1503,6 +1506,7 @@
15031506
</code></pre></div>
15041507

15051508
<ul>
1509+
<li><strong>For XML and binary Excel files (xlsx, xlsm and xlsb) use <a href="#dataframeplotencodedecode">Pandas</a> library.</strong></li>
15061510
<li><strong>File must be opened with a <code class="python hljs"><span class="hljs-string">'newline=""'</span></code> argument, or newlines embedded inside quoted fields will not be interpreted correctly!</strong></li>
15071511
</ul>
15081512
<div><h3 id="write">Write</h3><pre><code class="python language-python hljs">&lt;writer&gt; = csv.writer(&lt;file&gt;) <span class="hljs-comment"># Also: `dialect='excel', delimiter=','`.</span>
@@ -1879,7 +1883,7 @@
18791883
<li><strong>Coroutine definition starts with <code class="python hljs"><span class="hljs-string">'async'</span></code> and its call with <code class="python hljs"><span class="hljs-string">'await'</span></code>.</strong></li>
18801884
<li><strong><code class="python hljs"><span class="hljs-string">'asyncio.run(&lt;coroutine&gt;)'</span></code> is the main entry point for asynchronous programs.</strong></li>
18811885
<li><strong>Functions wait(), gather() and as_completed() can be used when multiple coroutines need to be started at the same time.</strong></li>
1882-
<li><strong>Asyncio module also provides its own <a href="#queue">Queue</a>, <a href="#semaphoreeventbarrier">Event</a>, <a href="#lock">Lock</a> and <a href="#semaphore-event-barrier">Semaphore</a> classes.</strong></li>
1886+
<li><strong>Asyncio module also provides its own <a href="#queue">Queue</a>, <a href="#semaphoreeventbarrier">Event</a>, <a href="#lock">Lock</a> and <a href="#semaphoreeventbarrier">Semaphore</a> classes.</strong></li>
18831887
</ul><div><h4 id="runsaterminalgamewhereyoucontrolanasteriskthatmustavoidnumbers">Runs a terminal game where you control an asterisk that must avoid numbers:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> asyncio, collections, curses, curses.textpad, enum, random
18841888

18851889
P = collections.namedtuple(<span class="hljs-string">'P'</span>, <span class="hljs-string">'x y'</span>) <span class="hljs-comment"># Position</span>
@@ -2887,7 +2891,7 @@
28872891

28882892

28892893
<footer>
2890-
<aside>April 20, 2022</aside>
2894+
<aside>May 2, 2022</aside>
28912895
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
28922896
</footer>
28932897

parse.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ function main() {
461461
function getMd() {
462462
var readme = readFile('README.md');
463463
var readme = readme.replace("#semaphore-event-barrier", "#semaphoreeventbarrier");
464+
var readme = readme.replace("#semaphore-event-barrier", "#semaphoreeventbarrier");
465+
var readme = readme.replace("#dataframe-plot-encode-decode", "#dataframeplotencodedecode");
464466
const converter = new showdown.Converter();
465467
return converter.makeHtml(readme);
466468
}

0 commit comments

Comments
 (0)