ReadRawFile

Language/Format: Numpy, Python
Application type(s): Data Read/Write
Related project(s):

Description

This tool is a generic Python module for reading for all binary files consisting in some headers followed by records with the same pattern.

Headers and record patterns are described in text files. Datasets are returned as Numpy arrays.

Limitation

In this version, multiple record patterns are not supported.

Usage

At the beginning of your Python code, add the line:

 from ReadRawFile import *

then use the following instruction:

 hdrs, dsets = ReadRawFile(file, hdr_descs, rec_desc, big [, dset_names])

where:

 file     : binary file to read
 hdr_descs: list of headers patterns description files
 rec_desc : record pattern description file
 big      : True if big-endian file, False otherwise
 dset_names: list of required dataset names (as defined in rec_desc);
  this argument can be omitted: in this case, all datasets are returned

A t-uple (hdrs, dsets) is returned, where hdrs and dsets are dictionnaries containing values for named variables of headers and record.

 

Download

Sources can be downloaded here :

ReadRawFile.v0.1.0.tgz

Package can be browsed here :

ReadRawFile

Compilation

Prerequisites

List prerequisites :

  • Python (2.5 ot higher)
  • Numpy (1.4 ot higher)

Environment

The module ReadRawFile.py must lie in a directory that will be scanned when searching Python Liraries.

You can copy the module in such a directory or add the parent directory of the module in the PYTHONPATH environment variable; if you are using the bash shell, this can be done via the export command :

> export PYTHONPATH=<Module Directory>:$PYTHONPATH 

Copyright

Copyright (C) 2010 Icare - http://www.icare.univ-lille1.fr

Bruno SIX, Bruno.Six@univ-lille1.fr

This program is a free software; you can redistribute it and/or modify it under the terms of the CeCILL Public License as published by www.cecill.info (License version 2 or later).

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL Public License for more details.

You should have received a copy of the CeCILL Public License along with this program; if not, please contact www.cecill.info

For any questions or concerns regarding this program, or general information about the ICARE Project, please email to contact@icare.univ-lille1.fr

Author(s): Bruno SIX (ICARE)