On Thu, Jun 25, 2009 at 10:32 AM, Private Private wrote:
> On Jun 24, 12:23 pm, Przemyslaw Bak wrote:
>> Hello,
>>
>> I many files with log data. The structure of the file is quite
>
> Each requested value is in separated file.
> While traversing using os.path.walk I have noticed that I get files
On Jun 24, 12:23 pm, Przemyslaw Bak wrote:
> Hello,
>
> I many files with log data. The structure of the file is quite
Each requested value is in separated file.
While traversing using os.path.walk I have noticed that I get files
unsorted.
Is it possible to get them sorted ?
przemol
--
http://m
On Jun 24, 11:00 pm, Peter Otten <__pete...@web.de> wrote:
> Private Private wrote:
> > > lines = fileinput.input(filename)
> > > for line in lines:
> > > if "Data2" in line:
> > > print line.strip(), "-->", next(lines).strip()
>
> > I get an error:
>
> > ...
> > print line.strip(),
Private Private wrote:
On Jun 24, 1:32 pm, Peter Otten <__pete...@web.de> wrote:
...
lines = fileinput.input(filename)
for line in lines:
if "Data2" in line:
print line.strip(), "-->", next(lines).strip()
I get an error:
...
print line.strip(), "-->", next(lines).strip()
Name
Private Private wrote:
> > lines = fileinput.input(filename)
> > for line in lines:
> > if "Data2" in line:
> > print line.strip(), "-->", next(lines).strip()
>
> I get an error:
>
> ...
> print line.strip(), "-->", next(lines).strip()
> NameError: global name 'next' is not defin
Peter Otten wrote:
Scott David Daniels wrote:
Peter Otten wrote:
with open(filename) as instream:
lines = (line.strip() for line in lines)
lookup = dict(zip(lines, lines))
Little bit of a fluff-up here.
Sorry, it should have been
with open(filename) as instream:
lines = (lin
On Jun 24, 1:32 pm, Peter Otten <__pete...@web.de> wrote:
> Przemyslaw Bak wrote:
> > Hello,
>
> > I many files with log data. The structure of the file is quite
> > inconvenience and similar to the following example:
> > Data1
> > ValueA
> > Data2
> > ValueB
> > Data3
> > ValueC
> > ...
> >
Scott David Daniels wrote:
> Peter Otten wrote:
>> with open(filename) as instream:
>> lines = (line.strip() for line in lines)
>> lookup = dict(zip(lines, lines))
> Little bit of a fluff-up here.
Sorry, it should have been
with open(filename) as instream:
lines = (line.strip()
Peter Otten wrote:
...
If you need more than a few name value pairs it pays to put the data in a
dictionary first:
# assuming that values always consist of a single line
with open(filename) as instream:
lines = (line.strip() for line in lines)
lookup = dict(zip(lines, lines))
print lo
Przemyslaw Bak wrote:
> Hello,
>
> I many files with log data. The structure of the file is quite
> inconvenience and similar to the following example:
> Data1
> ValueA
> Data2
> ValueB
> Data3
> ValueC
> ...
> To get the values I need to find Data* and then get to the next line.
> I tried
Hello,
I many files with log data. The structure of the file is quite
inconvenience and similar to the following example:
Data1
ValueA
Data2
ValueB
Data3
ValueC
...
To get the values I need to find Data* and then get to the next line.
I tried to use fileinput.input :
...
for line in fileinpu
11 matches
Mail list logo