jfblog

Random logs and notes

Some tests of argparse and configparser modules

Here are some notes on two modules of the standard library that can help to develop small scripts. The module argparse helps to parse the arguments to the script while the module configparser is useful for reading a particular textfile configuration.

Argparse examples

The argparse module of the standard library ...

Convert xls files to csv

I had to convert a bunch of xlsx files to csv. A simple solution is obtained thanks to the libraries in http://www.python-excel.org/. More specifically, I only had to use xlrd. It is as simple as

wb = xlrd.open_workbook(file)
sh = wb.sheet_by_name('Sheet1')

Now the sh object ...

Hamming_code

Hamming (7,4) coding

A colleague of mine asked me about a simple demonstration of Hamming code. It is inspired by this link, but unfortunately the code is not available anymore. Below is what I did.

Two utilitary functions

For encoding and decoding to and from binary number representations

In ...

Convert between matrices and arrays

Converting between arrays and matrices

When using numpy, it is sometimes useful to do part of calculations using matrices rather than arrays. Thus it is interesting to be able to convert between the two types. This is easily done as follows, where we use the * operator in functions definitions. This ...

Publishing on Github

The first thing to do is to create an account on Github pages and then follow the directions. This drives to

  • create a repository, say repo
  • and then create a gh-pages branch

then the content will be available (after a few minutes) in http://username.github.io/repo/

The point ...

The very first post

This is a text that describes that I am doing. First, I launch the pylab magic, with inline graphics.

In [2]:
%pylab inline
x=randn(100)
plot(x)
Populating the interactive namespace from numpy and matplotlib

Out[2]:
[<matplotlib.lines.Line2D at 0x7f093d3d7110>]
Read On ↵