binary vtk file
Robert Kern
robert.kern at gmail.com
Mon Oct 11 10:29:34 EDT 2010
On 10/11/10 5:16 AM, Paul Biegel wrote:
> Hi,
> I have a question related to read a binary vtk file. This file has been created
> using Matlab by
> the command "fread". However, this file must be processed further within Python.
> It is not
> known to me which codec is used to encode this file. It starts with the
> following characters:
> /1XùB4zBÑX•Cò¼ôA4zBÑX•C~BùB4zBÑ{–CnùB4zBJž—C •øB4zB·¿˜CÃ/
> //
> Has anyone an idea how to decode this in normal Python strings even if it is not
> known
> which character set must be used? Thanks in advance.
If it is a binary file and not text, it's nearly certain that you do not use
character sets or codecs at all. Those bytes do not represent text characters in
any encoding. You will have to look at your existing Matlab code to determine
how it is interpreting those bytes. Probably, they are just floating point
numbers, either single precision or double precision. You will probably want to
use numpy to read the file once you have discovered its format.
http://docs.scipy.org/doc/numpy/user/
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list