Hi to all,
thanks a lot! I am pretty sure your ideas help :-)
Greetings!
Fabian
--
http://mail.python.org/mailman/listinfo/python-list
On 6 Oct 2006 13:16:13 -0700, Matteo <[EMAIL PROTECTED]> wrote:
> Coming from C++, using exceptions in this way still feels a bit creepy
> to me, but I've been assured that this is very pythonic, and I'm slowly
> adopting this style in my python code.
>
> Parsing the line can be easy too:
>(um
Fabian Braennstroem wrote:
> Hi,
>
> I would like to remove certain lines from a log files. I had
> some sed/awk scripts for this, but now, I want to use python
> with its re module for this task.
>
> Actually, I have two different log files. The first file looks
> like:
>
>...
>'some text'
Fabian Braennstroem wrote:
> Hi,
>
>
> I actually want to extract the lines with the numbers, write
> them to a file and finally use gnuplot for plotting them. A
> nicer and more python way would be to extract those numbers,
> write them into an array according to their column and plot
> t
"Fabian Braennstroem" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I would like to remove certain lines from a log files. I had
> some sed/awk scripts for this, but now, I want to use python
> with its re module for this task.
>
> Actually, I have two different log files.
[EMAIL PROTECTED] wrote:
Use his solution like:
datafile = open(data_file_name, 'r')
for line in datafile:
if 'U-Mom' in line:
print float(line.split("|")[4])
datafile.close()
For the earlier problem:
def data_specific(source):
global headin
Fabian Braennstroem:
> A more difficult log file looks like:
> ...
> With my sed/awk/grep/gnuplot script I would extract the
> values in the 'U-Mom' row using grep and print a certain
> column (e.g. 'Max Res') to a file and print it with gnuplot.
> Maybe I have to remove those '|' using sed before.
Can you safely assume that the lines you want to extract all contain
numbers, and that the lines you do not wish to extract do not contain
numbers?
If so, you could just use the Linux grep utility: "grep '[0123456789]'
filename"
Or, in Python:
import re
inf = file("your-filename-here.txt")
outf
Hi Fabian,
I'm still a youngster in Python but I think I can help with the
"extracting data from the log file" part. As I'm seeing it right now,
the only character separating the numbers below is the space character.
You could try splitting all the lines by that character starting from
the NO Colum
Hi,
I would like to remove certain lines from a log files. I had
some sed/awk scripts for this, but now, I want to use python
with its re module for this task.
Actually, I have two different log files. The first file looks
like:
...
'some text'
...
ITER I- GL
10 matches
Mail list logo