473,395 Members | 1,937 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,395 software developers and data experts.

read() does not read whole file in activepython/DOS

This is what it looks like in DOS:
=======================================
C:\production>python
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>b = open('boot.bin').read()
len(b)
1067
>>import os
os.path.getsize('boot.bin')
18308L
=======================================

And this is what is says in cygwin:
=======================================
$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>b = open('boot.bin').read()
len(b)
18308
>>import os
os.path.getsize('boot.bin')
18308L
=======================================

What is wrong? / What am I doing wrong?
I would expect it to read the whole file.

Help appreciated :-)
Holger
Nov 7 '08 #1
1 2413
On Nov 7, 2:40*pm, Holger <ish...@gmail.comwrote:
This is what it looks like in DOS:
=======================================
C:\production>python
ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
Python 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.>>>b = open('boot.bin').read()
>len(b)
1067
>import os
os.path.getsize('boot.bin')

18308L
=======================================

What is wrong? / What am I doing wrong?
I would expect it to read the whole file.
Solution: open(<file>, 'rb')
Nov 7 '08 #2

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

Similar topics

6
by: PengYu.UT | last post by:
Hi, Suppose I a file with the following format --- each line is either a record or a blank line. If it is a record, it might be of one of the following format, where the first format means t...
1
by: Daniel | last post by:
does the windows file handle change? are file handles unique to the whole operating system or just the current directoy? if a file is opened then closed then opened again, does the file handle...
5
by: lovecreatesbea... | last post by:
The condition at line 31 is added to check if the program finished to read the whole file. Is it needed and correct? Thank you. #include <fstream> #include <iostream> #include <string> using...
2
by: NOSPAM plz | last post by:
Hey, My problem is, is it possible to download parts of a file while. i think is it is called threading My code thats download the whole webpage, and stunds the app while is is downloading: ...
8
by: Finger.Octopus | last post by:
Hi, Well, I want to read the contents of file in a character array. Actually, I am doing this for Hangman(game). I want to read the contents of file in a character array, so that I can pick a...
2
by: buzzy | last post by:
Hi!! I have a question here where I used : Open sourceDir & sourceFile For Input As af Do While Not EOF(af) Line Input #af, textline If Trim(textline) Like "fruits" Then ...
4
Mague
by: Mague | last post by:
I have got a website with a few friends from school(year8). We have got a website up. I want it so it looks for a textfile and reads and writes it into a textbox. It does do this. The only problem is...
4
by: Pacino | last post by:
Hi, everyone, I am wondering whether it's possible to read part (e.g. 1000*1000) of a huge jpeg file (e.g. 30000*30000) and save it to another jpeg file by pure python. I failed to read the...
3
by: mina2040 | last post by:
I know that I can read the whole file into a byte array and then convert the array to a stream using the following two lines: byte fileInBytes = File.ReadAllBytes(Filename); Stream fileInStream =...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.