comp.lang.python
  Home FAQ Contact Sign in
comp.lang.python only
 
Advanced search
July 2008
motuwethfrsasuw
 123456 27
78910111213 28
14151617181920 29
21222324252627 30
28293031    31
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.python Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  os.walk question         


Author: Lanny
Date: Jul 23, 2008 18:52

How would one make a list of the files in the top directory
using os.walk.

I need to pick a random file from said list.

Thanks.

-- Posted on news://freenews.netfront.net - Complaints to news@netfront.net --

no comments
  Re: maximum value in a column of file         


Author: Fredrik Lundh
Date: Jul 23, 2008 05:55

maurizio wrote:
> thank you for your answer
> actually i've to do some statistics (maximum,minimum,mean,standard
> deviation,....) of a file of data in which each column is a particular
> type of data. (the file is a tab separated value).
> I was trying to do this by using python (usually i work with fortran or
> bash, but i'm learning python), that the reason why i tried to use numpy.

As I implied, you can do all this in standard Python "by hand", but
numpy/scipy can definitely make things easier. There's a dependency
cost here (your program needs one or more extra libraries to work), but
if that's no problem in your environment, I'd recommend that approach.

The scipy add-on contains a bunch of things for file i/o; see

http://www.scipy.org/doc/api_docs/SciPy.io.html

for an overview. Since you're reading text files, the "array_import"
module seems to be what you need:

http://www.scipy.org/doc/api_docs/SciPy.io.array_import.html

There are active user communities for both numpy and scipy that can help
you sort out any remaining issues; for details, see:

http://www.scipy.org/Mailing_Lists
Show full article (1.16Kb)
no comments
  Re: Undefined calling conventions in Python.h         


Author: Fredrik Lundh
Date: Jul 23, 2008 04:44

Fredrik Lundh wrote:
>> cl cl -EHsc -MD -I \python25\include test.cc \python25\libs\python25.lib

cut and paste error there: the "cl cl" should be just one "cl", of course.

and just for the record/google, if I

1) don't include the header file, I get

test.cc(5) : error C3861: 'Py_Initialize': identifier not found, even
with argument-dependent lookup

2) attempt to undef the __cplusplus macro, I get

test.cc(1) : warning C4117: macro name '__cplusplus' is reserved,
'#undef' ignored

3) cut and paste declarations from the header files to my own file
instead of including the files, ignoring the extern "C" part, I get

test.obj : error LNK2019: unresolved external symbol "int __cdecl
Py_Finalize(void)" (?Py_Finalize@@YAHXZ) referenced in function _main

which looks pretty similar to the errors posted earlier.

no comments
  Re: logging into a website using python         


Author: Fredrik Lundh
Date: Jul 23, 2008 03:34

leo davis wrote:
> I''m trying achieve the following by running python programs
>
> -login to a website
> -automate filling up web forms
no comments
  Re: Re: maximum value in a column of file         


Author: maurizio
Date: Jul 23, 2008 03:20

thank you for your answer
actually i've to do some statistics (maximum,minimum,mean,standard
deviation,....) of a file of data in which each column is a particular
type of data. (the file is a tab separated value).
I was trying to do this by using python (usually i work with fortran or
bash, but i'm learning python), that the reason why i tried to use numpy.

Fredrik Lundh wrote:
>
maurizio
> wrote:
>
>> i tryed to use the module max of numpy,
>> the problem is that i don't know how to put the column...
Show full article (2.61Kb)
1 Comment
  Re: maximum value in a column of file         


Author: Fredrik Lundh
Date: Jul 23, 2008 02:44

maurizio wrote:
> i tryed to use the module max of numpy,
> the problem is that i don't know how to put the column of the file in an
> array.
> (i'm new in phyton).
> anyway if you think there is a better way.....

What kind of file is it? Did you pick numpy because you want to do
matrix operations (beyond just finding a maximum value), or was it just
the first thing you stumbled upon when researching the problem?

A simple pattern for finding the maximum value in a file, using only
plain Python code, is:

max_value = ... some very small value ...
for line in file:
value = ... extract value from line ...
if value > max_value:
max_value = value

If it's not obvious what "some very small value" is, given the range of
data you're working with, you can do
Show full article (2.06Kb)
no comments
  Re: maximum value in a column of file         


Author: Michiel Overtoom
Date: Jul 23, 2008 02:40

Maurizio wrote...
> the problem is that i don't know how to put the column of the file in an
> array. (i'm new in phyton).

Give us an example of how your file looks, and what you want to
extract from it, so that we don't have to guess.

Greetings,

--
"The ability of the OSS process to collect and harness
the collective IQ of thousands of individuals across
the Internet is simply amazing." - Vinod Vallopillil
http://www.catb.org/~esr/halloween/halloween4.html
no comments
  Re: software engineering foundations?         


Author: Fredrik Lundh
Date: Jul 23, 2008 02:22

skip@pobox.com wrote:
> In my work I have from time-to-time had to pick up and maintain
> scripts (generally shell/Python stuff) which non-professional programmers
> have written. It's never what you would call a "pleasant" task.

And yes, for the specific art of writing code that others might have to
read, see this short essay:

http://www.perforce.com/perforce/papers/prettycode.html

no comments
  Re: Re: maximum value in a column of file         


Author: maurizio
Date: Jul 23, 2008 02:07

i tryed to use the module max of numpy,
the problem is that i don't know how to put the column of the file in an
array.
(i'm new in phyton).
anyway if you think there is a better way.....

Fredrik Lundh wrote:
>
maurizio
> wrote:
>
>> which is the best way for the calculation of the maximum value in
>> a column of a file?
>
> what approach have you tried, and what happened when you tried it?
>
>
>
>
>
no comments
  Is this possible ....         


Author: Stef Mientki
Date: Jul 23, 2008 01:58

hello,

I'm looking for a way to remove duplicate code.
The problem is this:
In all my modules I've version information,
containing version information, date, author, testconditions etc,
something like this:

Version_Text = [
[ 0.2, '10-02-2008', 'Stef Mientki',
'Test Conditions:', (1,2),
_(0, """
- scaling and offset is set for each individual signal
- Time history window for 1 signal with min/max display
- set attributes for all signals at once
""") ],
Show full article (1.05Kb)
2 Comments
 
1 2 3 4 5 6 7 8 9