## Python module for processing a file line-by-line

Note: Since writing this post, I’ve learned about the fileinput module, which turns most of the following into a oneliner:

import fileinput for line in fileinput.input(): process(line)

## Benchmark: Reading uncompressed and compressed files from disc

In this post I’ll compare the running time of reading uncompressed and compressed files from disc.

I’ll run a test using two files, data.txt (858M) and data.txt.gz (83M), that have the same content.

The well-known command cat, prints the contents of a file. The lesser-known zcat, prints the contents of a GZIP’ed file.

## GDAL and OGR Python tips

Online documentation for GDAL/OGR Python is sparse. Here I show some recommended ways of learning more about GDAL/OGR in Python.

## Using Python interpreter

You can learn about GDAL and OGR from inside the Python interpreter.

Start python interpreter:

## Are IEEE papers getting less citations because of the paywall?

I’m in the process of doing research for my computer science ph.d. project. Like many others, I’m using Google Scholar to find interesting papers for my research. Some papers are available through ACM and some through IEEE.

## How to load an ESRI Shapefile into a PostGIS DB

Assuming a shapefile called myshapefile.shp, a table mytable in schema xyz, in a PostGIS enabled database called mydb on localhost. The table is owned by user dbuser who has password “secret”.

## Using shp2pgsql

shp2pgsql myshapefile -I xyz.mytable > statements.sql psql -d mydb -h localhost -U dbuser -f statements.sql

This tip and many more can be read in Making Maps Fast.

## Using ogr2ogr

This is even easier with ogr2ogr:

ogr2ogr -f "PostgreSQL" PG:"host=localhost user=dbuser dbname=mydb password=secret" -lco SCHEMA=xyz myshapefile.shp