Pyerg is a C++ library with a Python wrapper for reading the ERG files produced by IPG CarMaker program. The library implements the specifications of the ERG file format described in the IPG CarMaker reference manual.
Henesis s.r.l. is not affiliated with IPG, the developer of CarMaker program.
- Linux, Windows (tested within Anaconda)
- Python 2.7
- Numpy >= 1.7
- GCC >= 4.7
- CMake
- Google test library (optional, for building the C++ library)
Run python setup.py install to install the pyerg module.
Create a build directory in the current folder and from that directory run:
cmake ..
And then
make
The default behavior is to build a static (erg_s) and a shared (erg) version of the Erg parser library.
BUILD_PYTHON_MODULEenable the building of thepyergPython module. When building the Python module using CMake, please check that theNUMPY_INCLUDE_DIRin thepyerg/CMakeLists.txtcontains the right path to the Numpy headers.BUILD_TESTSenable the building test program for the C++ library. Data for testing is not included.
Use:
cmake .. -DBUILD_PYTHON_MODULE=ON -DBUILD_TESTS=ON
To build the C++ library, the Python pyerg module and the C++ tests.
#include <erg.h>
...
erg::Reader parser;
// Read all erg format
parser.open("my_file.erg");
// Allocate the destination memory using vector<byte> as container
std::vector<std::vector<uint8_t>> data(parser.numQuanities());
for(int i=0; i<data.size(); ++i)
data[i].assign(parser.quantitySize(i), 0);
// Create a vector of pointer to the allocated memory to
// store the data
std::vector<uint8_t*> dataPtrList;
std::vector<size_t> dataPtrListSize;
for(std::vector<uint8_t>& v: data)
{
dataPtrList.push_back(v.data());
dataPtrListSize.push_back(v.size());
}
size_t numRows = parser.readAll(dataPtrList, dataWrapperSize);
// data is a vector of vector<byte> with all the quantities from
// the erg file.
import pyerg
parser = pyerg.Reader()
parser.open("my_file.erg")
data = parser.readAll()
# data is a dict of numpy.ndarray with all the quantities from
# the erg file.
See the test applications for more usage examples.