473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Longint?!

Ivo
Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python
but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.

--
Cheerz,
Ivo.
http://IvoNet.nl
============================
Jul 18 '05 #1
4 1822
Ivo wrote:
Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python
but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.

maybe the module struct will help you....
Jul 18 '05 #2
Ivo wrote:
Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python
but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.


There is an sscanf module around (1995 Stichting Mathematisch Centrum)
which has a 'long' format control.
If you can't find it, I can send you the file.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #3
You must read it as binary and use struct.unpack() to convert
to long integer.

HTH,
Larry Bates
Syscon, Inc.

"Ivo" <Sp**@ivonet.nl> wrote in message
news:41*********************@reader20.nntp.hccnet. nl...
Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python
but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.

--
Cheerz,
Ivo.
http://IvoNet.nl
============================

Jul 18 '05 #4
Ivo
I will try the struct...
Thanx

--
Cheerz,
Ivo.
http://IvoNet.nl
============================
"Larry Bates" <lb****@swamisoft.com> wrote in message
news:6P********************@comcast.com...
You must read it as binary and use struct.unpack() to convert
to long integer.

HTH,
Larry Bates
Syscon, Inc.

"Ivo" <Sp**@ivonet.nl> wrote in message
news:41*********************@reader20.nntp.hccnet. nl...
Pythoneers,
I am trying to reed a long integer (4 byte value like in pascal) in python but i don't seem to succeed.

It's from a binary file where from a certain offset in the file 4 bytes
(longint) tell how long a header is.

because I don't have to assign a type to a variable I don't know how to
ensure i get the longint type read from the file.

Help very much appreciatend.

--
Cheerz,
Ivo.
http://IvoNet.nl
============================


Jul 18 '05 #5

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

Similar topics

28
by: dleecurt | last post by:
Hello, I have a small problem, I am trying to write a program that will calculate the Fibonacci number series, and I have the code complete with one problem. I used a long in to store the numbers,...
5
by: Alex Vinokur | last post by:
Functor-parameters in the for_each() and transform() algorithms are passed by value. Might it make sense to have also algorithms for_each2() and transform2() which pass Functor-parameters by...
3
by: Adolfo López Escribano | last post by:
I'm try to launch db2Backup from Borland Delphi, but I obtain an undocumented SQLCODE -1152. Any idea? My code is the next: Type Tsqlca = record sqlcaid: Array of Char; sqlcabc: LongInt;...
8
by: jake1138 | last post by:
Maybe this is a newbie thing and everyone already knows how to do this, but I figured I'd post these functions anyway in case someone finds them useful. I used Jack Klein's example (see link...
1
by: ARTMIC | last post by:
Hello, could someone please help me out, i'm trying to call a Delphi 6.0 custom DLL from inside of a C# windows project. what am i doing wrong? i use the following declaration: public class...
1
by: ARTMIC | last post by:
Hello, could someone please help me out, i'm trying to call a Delphi 6.0 custom DLL from inside of a C# windows project. i use the following declaration: static extern double...
4
by: quakersquares | last post by:
I am writing a C++ program for class, I am fairly new to C++ but have plenty of programming history. I have to split up a integer into an array. but I am having trouble just getting the count for the...
5
by: quakersquares | last post by:
As part of a program I have to multiply two long numbers out, numbers that dont fit in any int. I feel that I have the algorithm right, but somehow the code just isnt working out and I cannot see...
6
by: =?Utf-8?B?QWxleGFuZGVyZmU=?= | last post by:
Hi, I have a C# program that uses an unmanaged dll that has a function similar to the signature below : void f(out MyStruct arr, out int num); // num = actual array length returned The array...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.