Re: [newbie] Saving binaries in a specific way

2013-12-17 Thread Djoser
Thank you.
With numpy it works perfectly. I thought it would lost the information about 
int32 and int16 with this approach.

Now I will try to make the script with struct too, but I'll need a bit more 
time to really understand. For me it's a new paradigm. But that's nice. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


[newbie] Saving binaries in a specific way

2013-12-16 Thread Djoser
Hi all,

I am new to this forum and also to Python, but I'm trying hard to understand it 
 better.
I need to create a binary file, but the first 4 lines must be in 
signed-Integer16 and all the others in signed-Integer32. I have a program that 
does that with Matlab and other with Mathematica, but I'm converting all for 
Python.

I tried first to convert the number to binary using 'bin(number'), than I 
removed the '0b' and converted to 'Int16' or 'Int32', but with this approach I 
can't save a binary file using 'bytearray(').

How can I do that?


Thanks in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Saving binaries in a specific way

2013-12-16 Thread Djoser
I'm using python 2.7.
If I understood correctly, using bytearray I will lost the information about 
the signed 16, 32, since it makes automatically the conversion.

Do you think that I can make the conversion as I proposed before or using 
struct and save with open()? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Saving binaries in a specific way

2013-12-16 Thread Djoser
Basically I have a .dat file, so I get some numbers and make a different 
conversion.
I'll try this struct script. I'm not used to it, but it seems to do what I want.
-- 
https://mail.python.org/mailman/listinfo/python-list