473,545 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read and write binary data

Hi guys,
I am new to Python, and thinking about migrating to it from matlab
as it is a really cool language. Right now, I am trying to figure out
how to control read and write binary data, like
'formatted','st ream','big-endian','little-edian' etc.. as in fortran.
I googled, but can not find a clear answer. Anyone has clue where can
I learn it? Thanks!!
Jinbo
Sep 7 '08 #1
5 2616
On Sep 7, 5:41*pm, Mars creature <jin...@gmail.c omwrote:
Hi guys,
* I am new to Python, and thinking about migrating to it from matlab
as it is a really cool language. Right now, I am trying to figure out
how to control read and write binary data, like
'formatted','st ream','big-endian','little-edian' etc.. as in fortran.
I googled, but can not find a clear answer. Anyone has clue where can
I learn it? Thanks!!
Jinbo
Start by looking at the array module.

Regards,
Pat
Sep 8 '08 #2
On Sep 7, 8:55 pm, Patrick Maupin <pmau...@gmail. comwrote:
On Sep 7, 5:41 pm, Mars creature <jin...@gmail.c omwrote:
Hi guys,
I am new to Python, and thinking about migrating to it from matlab
as it is a really cool language. Right now, I am trying to figure out
how to control read and write binary data, like
'formatted','st ream','big-endian','little-edian' etc.. as in fortran.
I googled, but can not find a clear answer. Anyone has clue where can
I learn it? Thanks!!
Jinbo

Start by looking at the array module.

Regards,
Pat
Thanks!!
Sep 8 '08 #3
On Sun, Sep 7, 2008 at 5:41 PM, Mars creature <ji****@gmail.c omwrote:
Hi guys,
I am new to Python, and thinking about migrating to it from matlab
as it is a really cool language. Right now, I am trying to figure out
If you're trying to migrate from matlab to python I'd take a look at numpy:

http://numpy.scipy.org/

And scipy which is built on top of numpy:

http://www.scipy.org/

There is a plotting/numerical computation package known as matplotlib
that does its best to parallel matlab commands:

http://matplotlib.sourceforge.net/

There is support for reading and writing binary data, even fortran records.

And last but not least, you can always take a look at the scipy and
numpy mailing lists.

Good luck,

Kurt
how to control read and write binary data, like
'formatted','st ream','big-endian','little-edian' etc.. as in fortran.
I googled, but can not find a clear answer. Anyone has clue where can
I learn it? Thanks!!
Jinbo
--
http://mail.python.org/mailman/listinfo/python-list
Sep 8 '08 #4
I don't know if this is going to help you
but a free&open alternative to Matlap is FreeMat just search for it
Sep 8 '08 #5
On Sep 7, 6:41 pm, Mars creature <jin...@gmail.c omwrote:
Hi guys,
I am new to Python, and thinking about migrating to it from matlab
as it is a really cool language. Right now, I am trying to figure out
how to control read and write binary data, like
'formatted','st ream','big-endian','little-edian' etc.. as in fortran.
I googled, but can not find a clear answer. Anyone has clue where can
I learn it? Thanks!!
Jinbo
the struct module should be useful
Sep 10 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3700
by: Albert Tu | last post by:
Dear there, We have an x-ray CT system. The acquisition computer acquires x-ray projections and outputs multiple data files in binary format (2-byte unsigned integer) such as projection0.raw, projection1.raw, projection2.raw ... up to projection500.raw. Each file is 2*1024*768-byte big. I would like to read those files and convert to...
19
2684
by: Holger Hasselbach | last post by:
- The value of the object allocated by the malloc function is used (7.20.3.3). - The value of any bytes in a new object allocated by the realloc function beyond the size of the old object are used (7.20.3.4). Something like this (include and checkings omitted): p = malloc(sizeof(*p) * 5); p = 1; p = 1; p = 1;
7
4525
by: Mike Stephens | last post by:
I have a requirement to read / write to a proprietary data file. The fill will have no more than 10 records with no more than 10 fields. This is only for very simple data access. I want to completely avoid using ADO and XML. If someone can please point me in the right dirrection. Regards, Mike.
9
5134
by: sweety | last post by:
Dear All, How to encrypt a C data file and make binary file and then have to read a bin file at run time and decrypt the file and have to read the data. Any help to achive this pls. Would be great if any sample source code provided. Thanks, Sweety
3
18956
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its original form. The problem is tha the binary source that I extract from the text file seems to be diferent from the source I saved. Here is my code: 1)...
6
7359
by: ericunfuk | last post by:
Hi ALL, I want to read a binary file(it's pic.tif file, I guess it's binary file?), then write it to a new file), I have several questions about this process: When I use fread() to read a chunk of the file into a buffer, when it encounters the end of the file, will the EOF indicator be put into the buffer automatically just as an...
9
3834
by: vineeth | last post by:
Hello all, I have come across a weird problem, I need to determine the amount of bytes read from a file, but couldn't figure it out , My program does this : __ file = open("somefile") data = file.read() print "bytes read ", len(data) ---
4
2774
by: zl2k | last post by:
hi, there I have a appendable binary file of complex data structure named data.bin created by myself. It is written in the following format: number of Data, Data array Suppose I have following data.bin (3 Data appended to 2 Data): 2, data0, data1, 3, data0, data1, data2
5
11226
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a couple areas that have ASCII text that I need to extract. At the end of the 2580 bytes, I can read the report like a standard text file. It should have...
1
3918
by: Sachin Garg | last post by:
I have a program which opens a fstream in binary input+output mode, creating the file if it doesn't exists. But writing doesn't works after reading, it must be something obvious that I am not aware of. f.open(filename,ios::in | ios::out | ios::binary | ios::trunc) The program flow is 1) write some data 2) read the data
0
7479
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7411
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7439
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5987
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.