Le mardi 29 octobre 2019 10:34:22 UTC+1, Inada Naoki a écrit :
> When you are reading file from stdin, fileinput doesn't open the file.
> Python open the stdin. So openhook doesn't affect to stdin.
>
> You can use stdin.reconfigure() to change encoding and error handler
> of the stdin.
>
> On Tu
When you are reading file from stdin, fileinput doesn't open the file.
Python open the stdin. So openhook doesn't affect to stdin.
You can use stdin.reconfigure() to change encoding and error handler
of the stdin.
On Tue, Oct 29, 2019 at 6:31 PM wrote:
>
> Le lundi 28 octobre 2019 11:48:29 UTC+
Le lundi 28 octobre 2019 11:48:29 UTC+1, Peter J. Holzer a écrit :
> On 2019-10-25 22:12:23 +0200, Pascal wrote:
> > for line in fileinput.input(source):
> > print(line.strip())
> >
> > ---
> >
> > python3.7.4 myscript.py myfile.log
> > Traceback (most recent call last):
>
On 2019-10-25 22:12:23 +0200, Pascal wrote:
> for line in fileinput.input(source):
> print(line.strip())
>
> ---
>
> python3.7.4 myscript.py myfile.log
> Traceback (most recent call last):
> ...
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe8 in position 799:
>
Le samedi 26 octobre 2019 17:49:57 UTC+2, Peter Otten a écrit :
> Pascal wrote:
>
> > I have a small python (3.7.4) script that should open a log file and
> > display its content but as you can see, an encoding error occurs :
> >
> > ---
> >
> > import fileinput
> > import sy
Pascal wrote:
> I have a small python (3.7.4) script that should open a log file and
> display its content but as you can see, an encoding error occurs :
>
> ---
>
> import fileinput
> import sys
> try:
> source = sys.argv[1:]
> except IndexError:
> source = None
> fo
>
> If you're certain that the headers are the same in each file,
> then there's no harm and much simplicity in reading them each
> time they come up.
>
> with fileinput ...:
> for line in f:
> if fileinput.isfirstline():
> headers = extract_headers(line)
> On 7 Sep 2019, at 16:33, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com>
> wrote:
>
>with fileinput ...:
>for line in f:
>if fileinput.isfirstline():
>headers = extract_headers(line)
>else:
>pass # process a non-header line
On 9/7/19 11:12 AM, Jason Friedman wrote:
$ grep "File number" ~/result | sort | uniq
File number: 3
I expected that last grep to yield:
File number: 1
File number: 2
File number: 3
File number: 4
File number: 5
File number: 6
As per https://docs.python.org/3/library/fileinput.html#fileinput.
On 1/4/2010 5:35 PM, wiso wrote:
I'm trying the fileinput module, and I like it, but I don't understand why
it's so slow... look:
from time import time
from fileinput import FileInput
file = ['r1_200907.log', 'r1_200908.log', 'r1_200909.log', 'r1_200910.log',
'r1_200911.log']
def f1():
n =
On Mon, 04 Jan 2010 23:35:02 +0100, wiso wrote:
> I'm trying the fileinput module, and I like it, but I don't understand
> why it's so slow...
Because it is written for convenience, not speed. From the source code:
"Performance: this module is unfortunately one of the slower ways of
processing
En Mon, 04 Jan 2010 19:35:02 -0300, wiso escribió:
I'm trying the fileinput module, and I like it, but I don't understand
why
it's so slow... look:
from time import time
from fileinput import FileInput
file = ['r1_200907.log', 'r1_200908.log', 'r1_200909.log',
'r1_200910.log',
'r1_200911
On Aug 13, 11:41 pm, naaman wrote:
> On Aug 13, 7:50 am, Dave Angel wrote:
>
>
>
> > naaman wrote:
> > > On Aug 12, 1:35 pm, Dave Angel wrote:
>
> > >> naaman wrote:
>
> > >>> I'm writing my first Python script and
> > >>> I want to use fileinput to open a file in r+ mode.
> > >>> Tried fileinpu
On Aug 13, 7:50 am, Dave Angel wrote:
> naaman wrote:
> > On Aug 12, 1:35 pm, Dave Angel wrote:
>
> >> naaman wrote:
>
> >>> I'm writing my first Python script and
> >>> I want to use fileinput to open a file in r+ mode.
> >>> Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
> >>> A
On Aug 13, 1:20 am, "Gabriel Genellina"
wrote:
> En Wed, 12 Aug 2009 01:27:47 -0300, naaman escribió:
>
> > I'm writing my first Python script and
> > I want to use fileinput to open a file in r+ mode.
> > Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
> > ANy ideas?
>
> Don't use
On Aug 13, 7:50 am, Dave Angel wrote:
> naaman wrote:
> > On Aug 12, 1:35 pm, Dave Angel wrote:
>
> >> naaman wrote:
>
> >>> I'm writing my first Python script and
> >>> I want to use fileinput to open a file in r+ mode.
> >>> Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
> >>> A
On Aug 13, 7:50 am, Dave Angel wrote:
> naaman wrote:
> > On Aug 12, 1:35 pm, Dave Angel wrote:
>
> >> naaman wrote:
>
> >>> I'm writing my first Python script and
> >>> I want to use fileinput to open a file in r+ mode.
> >>> Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
> >>> A
naaman wrote:
On Aug 12, 1:35 pm, Dave Angel wrote:
naaman wrote:
I'm writing my first Python script and
I want to use fileinput to open a file in r+ mode.
Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
ANy ideas?
Need to find and overwrite a line in a file sever
En Wed, 12 Aug 2009 01:27:47 -0300, naaman escribió:
I'm writing my first Python script and
I want to use fileinput to open a file in r+ mode.
Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
ANy ideas?
Don't use fileinput, it can't handle r+, only sequencial access.
Even if you
On Aug 12, 1:35 pm, Dave Angel wrote:
> naaman wrote:
> > I'm writing my first Python script and
> > I want to use fileinput to open a file in r+ mode.
> > Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
> > ANy ideas?
>
> > Need to find and overwrite a line in a file several times.
naaman wrote:
I'm writing my first Python script and
I want to use fileinput to open a file in r+ mode.
Tried fileinput.input(sys.argv[1:],"r+") but that didn't work.
ANy ideas?
Need to find and overwrite a line in a file several times.
I can do it using open and seek() etc. but was wondering if
21 matches
Mail list logo