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

binary file

L.S.,

I have used the profile module to measure some thing as the next command:

profile.run('command', 'file')

But this make a binary file! How can I write the result of 'profile' in
a ascii file? Others how can I read (or convert) the binary file to am
ascii file?

Regards,
Nader
Jul 19 '05 #1
4 2076
Nader Emami wrote:
L.S.,

I have used the profile module to measure some thing as the next command:

profile.run('command', 'file')

But this make a binary file! How can I write the result of 'profile' in
a ascii file? Others how can I read (or convert) the binary file to am
ascii file?


Use an instance of pstats.Stats to interpret the results:

from pstats import Stats
s = Stats('file')
s.print_stats()

etc.
http://docs.python.org/lib/profile-stats.html

Kent
Jul 19 '05 #2
Kent Johnson wrote:
Nader Emami wrote:
L.S.,

I have used the profile module to measure some thing as the next command:

profile.run('command', 'file')

But this make a binary file! How can I write the result of 'profile'
in a ascii file? Others how can I read (or convert) the binary file to
am ascii file?

Use an instance of pstats.Stats to interpret the results:

from pstats import Stats
s = Stats('file')
s.print_stats()

etc.
http://docs.python.org/lib/profile-stats.html

Kent

I got the same result as the execution of command. But I would like to
write to the an external 'ascii' file!

Thanks!

Jul 19 '05 #3
Nader Emami wrote:
Kent Johnson wrote:
Nader Emami wrote:
L.S.,

I have used the profile module to measure some thing as the next
command:

profile.run('command', 'file')

But this make a binary file! How can I write the result of 'profile'
in a ascii file? Others how can I read (or convert) the binary file
to am ascii file?


Use an instance of pstats.Stats to interpret the results:

from pstats import Stats
s = Stats('file')
s.print_stats()

etc.
http://docs.python.org/lib/profile-stats.html

Kent


I got the same result as the execution of command. But I would like to
write to the an external 'ascii' file!


Oh, I get it, pstats.Stats doesn't have a way to send the output to a file. That's surprising!

One option would be to write a program that outputs what you want, then redirect the output in the shell. Alternatively take a look a the source for print_stats() and write your own that outputs to a file.

Kent
Jul 19 '05 #4
Kent Johnson wrote:
Nader Emami wrote:
Kent Johnson wrote:
Nader Emami wrote:
I have used the profile module to measure some thing as the next
command:
profile.run('command', 'file')
...How can I read (or convert) the binary file to an ascii file?
Use an instance of pstats.Stats to interpret the results:
from pstats import Stats
s = Stats('file')
s.print_stats()

I got the same result as the execution of command. But I would like to
write to the an external 'ascii' file!

Oh, I get it, pstats.Stats doesn't have a way to send the output to a
file. That's surprising!

I may be missing something here, but:
import sys, pstats

s = pstats.Stats('file')
sys.stdout, old = open('somefile.txt', 'w'), sys.stdout
s.print_stats()
sys.stdout, old = old, sys.stdout
old.close()
Looks to solve your problem to me.

--Scott David Daniels
Sc***********@Acm.Org
Jul 19 '05 #5

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

Similar topics

13
by: yaipa | last post by:
What would be the common sense way of finding a binary pattern in a ..bin file, say some 200 bytes, and replacing it with an updated pattern of the same length at the same offset? Also, the...
28
by: wwj | last post by:
void main() { char* p="Hello"; printf("%s",p); *p='w'; printf("%s",p); }
9
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
3
by: John R. Delaney | last post by:
I am running in debugging mode after a clean C++ compilation under .NET 2003. In a BIG loop (controlled many levels up in the call stack), I open a file with fopen using the "a" option. Then I write...
5
by: Neo | last post by:
Hello: I am receiving a Binary File in a Request from a application. The stream which comes to me has the boundary (Something like "---------------------------39<WBR>­0C0F3E0099" without the...
12
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: ...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
10
by: rory | last post by:
I can't seem to append a string to the end of a binary file. I'm using the following code: fstream outFile("test.exe", ios::in | ios::out | ios::binary | ios::ate | ios::app)...
16
by: Erwin Moller | last post by:
Why is a binary file executable? Is any binary file executable? Is only binary file executable? Are all executable files binary? What is the connection between the attribute of binary and that of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: 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: 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...

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.