<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Python on Neil Grogan</title><link>/tags/python/</link><description>Recent content in Python on Neil Grogan</description><generator>Hugo -- 0.135.0</generator><language>en-us</language><copyright>2004-present Neil Grogan</copyright><lastBuildDate>Sun, 21 Apr 2024 00:00:00 +0000</lastBuildDate><atom:link href="/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>HomeAssistant Yellow Review</title><link>/ha-yellow-review/</link><pubDate>Sun, 21 Apr 2024 00:00:00 +0000</pubDate><guid>/ha-yellow-review/</guid><description>&lt;p>For Christmas as a gift to myself I bought a HomeAssistant Yellow. If you&amp;rsquo;re not
familiar with HomeAssistant - it&amp;rsquo;s a one-stop-shop to control all your smart
lights, plugs, sensors and anything else in your smart home. HomeAssistant is
the software part and as it&amp;rsquo;s open source you can freely install it on any
computer you have. In fact many people install HomeAssistant on a Raspberry Pi.&lt;/p>
&lt;p>HomeAssistant Yellow is their own custom hardware with a built in chip for
Zigbee (and now Threads) protocol, along with Bluetooth, WiFi and audio out. It
takes a Raspberry Pi compute module 4 as its &amp;ldquo;brains&amp;rdquo;. This technically means it
should - emphasis on &lt;em>should&lt;/em> be upgradeable if a Raspberry Pi compute module 5
that is compatible with CM4 socket is produced.&lt;/p></description></item><item><title>Convert Bank Transactions XLS to CSV in Python</title><link>/bank-xls-csv/</link><pubDate>Fri, 25 Nov 2022 00:00:00 +0000</pubDate><guid>/bank-xls-csv/</guid><description>&lt;p>I&amp;rsquo;ve written previously on importing transactions to hledger/&lt;a href="../../ledger">ledger&lt;/a> from
&lt;a href="../../kbc-tx-js">KBC&lt;/a> bank in JavaScript and &lt;a href="../../bank-tx-py">PTSB&lt;/a> bank in Python. I took different
approaches to each:&lt;/p>
&lt;ul>
&lt;li>For KBC, you needed to log in and run Javascript which scrape the transaction
table and download it formatted as CSV&lt;/li>
&lt;li>For PTSB, the script automatted logging in, get the transaction table and save
locally as CSV&lt;/li>
&lt;/ul>
&lt;p>Both approaches are valid - but suffer from the same issues: any change the bank
makes to it website needs to be updated in the code. The KBC/JavaScript approach
was a bit more robust in that it would just search for rows on a website and
download as CSV.&lt;/p></description></item><item><title>Python 3 In-Memory Zip File</title><link>/py-bin-zip/</link><pubDate>Sun, 14 Jan 2018 00:00:00 +0000</pubDate><guid>/py-bin-zip/</guid><description>&lt;p>
In Python, &lt;a href="https://docs.python.org/3/library/io.html#io.BytesIO">BytesIO&lt;/a> is the way to store binary data in memory. Most examples you’ll see using zip files in memory is to store string data and indeed the most common example you’ll find online from the &lt;a href="https://docs.python.org/3/library/zipfile.html">zipfile&lt;/a> module is &lt;code>zipfile.writestr(file_name, &amp;#34;Text Data&amp;#34;)&lt;/code>. But what if you want to store binary data of a PDF or Excel Spreadsheet that’s also in memory? You could use &lt;code>zipfile.write()&lt;/code> (designed to take binary data) but then you can’t specify a filename (since our in-memory file was never written to a location on disk). The reason for this is simple: for a web request or for a test case, you shouldn’t need to store any files on disk.&lt;/p></description></item><item><title>Scraping Data from your Bank in Python</title><link>/bank-tx-py/</link><pubDate>Wed, 12 Jul 2017 00:00:00 +0000</pubDate><guid>/bank-tx-py/</guid><description>&lt;p>As part of my previous posts, I talked about &lt;a href="../../ledger">ledger&lt;/a> and plain text
accounting. The only part missing is that you need a method to import
transactions from your bank. For this I have been doing this by hand, bi-weekly.
I would have to do the following:&lt;/p>
&lt;ol>
&lt;li>Log in to online banking&lt;/li>
&lt;li>Go to the transactions page&lt;/li>
&lt;li>Select the date range for transactions I needed (double check last date of
transaction in ledger at this point)&lt;/li>
&lt;li>Download the &lt;a href="https://en.wikipedia.org/wiki/Microsoft_Excel">Microsoft Excel&lt;/a> format file that wasn&amp;rsquo;t in the proper format&lt;/li>
&lt;li>Convert this Excel file into a CSV file that matched my import format (watch
the dates, is it YYYY-MM-DD or DD/MM/YYYY?)&lt;/li>
&lt;li>Finally import the CSV file into ledger&lt;/li>
&lt;li>Check the balance matches between my online banking and ledger&lt;/li>
&lt;/ol>
&lt;p>&lt;em>Sounds like a lot of work right?&lt;/em>&lt;/p></description></item><item><title>Fill hours worked in SAP Netweaver Automatically</title><link>/autohours/</link><pubDate>Mon, 01 Feb 2016 00:00:00 +0000</pubDate><guid>/autohours/</guid><description>&lt;p>Continuing the theme of automation, one of the most repetitive tasks if you work
for a big company is timesheets. So I set out to rectify this by scripting it!&lt;/p>
&lt;p>Start with you configuration, I named mine &lt;code>hours.ini&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span>[DEFAULT]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>url &lt;span style="color:#f92672">=&lt;/span> FILL_ME_IN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>username &lt;span style="color:#f92672">=&lt;/span> FILL_ME_IN
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>password &lt;span style="color:#f92672">=&lt;/span> FILL_ME_IN
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>then we need the magic of &lt;a href="http://www.seleniumhq.org/">Selenium&lt;/a> to do the heavy
lifting, so we install it:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>$ pip3 install selenium
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>I called this script, unsurprisingly &lt;code>hours.py&lt;/code>:&lt;/p></description></item></channel></rss>