Wednesday, 20 August 2014

A very brief comparison of few Python tools for working with Excel files

As a part of a small Python script, it was required to export some data to Excel spreadsheet. I had a quick search to see what are the options and found these two packages:

  • xlutils (xlrd for reading and xlwt for writing): it was simple and straightforward to use it, but I encountered a couple of issues with it: if your output has more than 256 columns, then you're partially in trouble! This is a limitation of older Excel formats (xls), Excel 2003 and greater (with xlsx format), does not have that problem. But this package is not very happy with xlxs, e.g. it does not support keeping the format of xlxs files. So I'd recommend to try the next package.
  • openpyxl is more compatible with xlxs and does not have separate reader/writer classes and is simpler than xlutils to use. Keeping formatting and other issues with xlxs files are better supported here and ended up using this package.
As the title says, this is a very brief and most probably not too much accurate comparison of the two packages, but just wanted to share this short experience!

Saturday, 2 August 2014

Using OpenSSL in Windows and PowerShell

OpenSSL has no official binary distribution for Windows, however there is a semi-official version from Shining Light Productions (a compiled + installer version of the official OpenSSL which is free to download and use). It can be downloaded from this page. The very simple problem of using that binaries is that it can't find the config file (it tried to load it from /usr/local/ssl/openssl.cnf and fails with this message WARNING: can't open config file: /usr/local/ssl/openssl.cnf)
If you're using Windows' default shell (Command Prompt), then you can specify the config file manually by running this command: Alternatively if you're on PowerShell, run this command to add the correct path of the config file to the environment variable name OPENSSL_CONF:
No need to mention that you need to specify the correct path to the openssl.cfg file according to the installation path of OpenSSL.
An alternative solution is to edit the source code manually and change the default path of the config file and then compile it and so forth.