Michael Torrie writes:
> On 3/25/21 1:14 AM, Loris Bennett wrote:
>> Does any one have a better approach?
>
> Not as such. Running a command and parsing its output is a relatively
> common task. Years ago I wrote my own simple python wrapper function
> that would make it easier to run a program
Many thanks for the link to that document. Most helpful.
Peter
> -Original Message-
> From: Michael Torrie
> Sent: Friday, March 26, 2021 8:32 PM
> To: python-list@python.org
> Subject: Re: convert script awk in python
>
> On 3/25/21 1:14 AM, Loris Bennett wrote:
plit!
∀vi ∃. Grθß
-Original Message-
From: Python-list On
Behalf Of 2qdxy4rzwzuui...@potatochowder.com
Sent: Friday, March 26, 2021 9:43 PM
To: python-list@python.org
Subject: Re: convert script awk in python
On 2021-03-26 at 21:06:19 -0400,
Avi Gross via Python-list wrote:
> A generat
On 2021-03-26 at 21:06:19 -0400,
Avi Gross via Python-list wrote:
> A generator that opens one file at a time (or STDIN) in a consistent
> manner, would be a reasonable thing to have as part of emulating AWK.
https://docs.python.org/3/library/fileinput.html
--
https://mail.python.org/mailman/li
26, 2021 8:32 PM
To: python-list@python.org
Subject: Re: convert script awk in python
On 3/25/21 1:14 AM, Loris Bennett wrote:
> Does any one have a better approach?
Not as such. Running a command and parsing its output is a relatively
common task. Years ago I wrote my own simple python wrapper
On 3/25/21 1:14 AM, Loris Bennett wrote:
> Does any one have a better approach?
Not as such. Running a command and parsing its output is a relatively
common task. Years ago I wrote my own simple python wrapper function
that would make it easier to run a program with arguments, and capture
its out
Christian Gollwitzer writes:
> The closest equivalent I can come up with in Python is this:
>
> ==
> import sys
>
> s=0
> for line in sys.stdin:
> try:
> s += float(line.split()[1])
> except:
> pass
> print(s)
> =
s?
-Original Message-
From: Python-list On
Behalf Of Cameron Simpson
Sent: Tuesday, March 23, 2021 6:38 PM
To: Tomasz Rola
Cc: Avi Gross via Python-list
Subject: Re: convert script awk in python
On 23Mar2021 16:37, Tomasz Rola wrote:
On Tue, Mar 23, 2021 at 10:40:01AM -0400, Avi Gro
thought of calling 'xargs' via
Popen, but this seemed very fiddly (I didn't manage to get it working)
and anyway seemed a bit weird to me as it is really just a loop, which I
can implement perfectly well in Python.
Cheers,
Loris
>> seff_output = []
>>
all seems a bit laboured.
Does any one have a better approach?
Cheers,
Loris
-Original Message-
From: Cameron Simpson
Sent: Wednesday, March 24, 2021 6:34 PM
To: Avi Gross
Cc: python-list@python.org
Subject: Re: convert script awk in python
On 24Mar2021 12:00, Avi Gross wrote:
Bu
Am 25.03.21 um 00:30 schrieb Avi Gross:
It [awk] is, as noted, a great tool and if you only had one or a few tools like
it
available, it can easily be bent and twisted to do much of what the others
do as it is more programmable than most. But following that line of
reasoning, fairly simple pytho
seff_output.append(str(line.strip(), "UTF-8"))
...
but compared the to the bash pipeline, this all seems a bit laboured.
Does any one have a better approach?
Cheers,
Loris
> -Original Message-
> From: Cameron Simpson
> Sent: Wednesd
-
From: Cameron Simpson
Sent: Wednesday, March 24, 2021 6:34 PM
To: Avi Gross
Cc: python-list@python.org
Subject: Re: convert script awk in python
On 24Mar2021 12:00, Avi Gross wrote:
>But I wonder how much languages like AWK are still used to make new
>programs as compared to a time
On 24Mar2021 12:00, Avi Gross wrote:
>But I wonder how much languages like AWK are still used to make new
>programs
>as compared to a time they were really useful.
You mentioned in an adjacent post that you've not used AWK since 2000.
By contrast, I still use it regularly.
It's great for proo
On 24/03/2021 16:00, Avi Gross via Python-list wrote:
> But I wonder how much languages like AWK are still used to make new programs
> as compared to a time they were really useful.
True. I first discovered awk from a Byte article around 1988/9
and it became my goto tool for text munching right u
n-list On
Behalf Of Alan Gauld via Python-list
Sent: Wednesday, March 24, 2021 5:28 AM
To: python-list@python.org
Subject: Re: convert script awk in python
On 23/03/2021 14:40, Avi Gross via Python-list wrote:
> $1 == 113 {
> if (x || y || z)
> print "More than one ty
On 23/03/2021 14:40, Avi Gross via Python-list wrote:
> $1 == 113 {
> if (x || y || z)
> print "More than one type $8 atom.";
> else {
> x = $2; y = $3; z = $4;
> istep++;
> }
> }
>
> I am a tod concerned as to where any of the variables x, y or z have been
> d
anslator by just saving some JSON descriptions?
-Original Message-
From: Python-list On
Behalf Of Cameron Simpson
Sent: Tuesday, March 23, 2021 6:38 PM
To: Tomasz Rola
Cc: Avi Gross via Python-list
Subject: Re: convert script awk in python
On 23Mar2021 16:37, Tomasz Rola wrote:
>On Tue, M
On 23Mar2021 16:37, Tomasz Rola wrote:
>On Tue, Mar 23, 2021 at 10:40:01AM -0400, Avi Gross via Python-list wrote:
>[...]
>> I am a tod concerned as to where any of the variables x, y or z have been
>> defined at this point. I have not seen a BEGIN {...} pattern/action or
>> anywhere these have be
On Tue, Mar 23, 2021 at 10:40:01AM -0400, Avi Gross via Python-list wrote:
> Alberto,
>
[...]
> I am a tod concerned as to where any of the variables x, y or z have been
> defined at this point. I have not seen a BEGIN {...} pattern/action or
> anywhere these have been initialized but they are set
Alberto,
To convert any algorithm to python (or anything else) you have to understand
it. Do you know what AWK is doing? And does the darn thing work already in
awk? Why do you need to convert it? My suspicion is that it has errors and
if so, it is NOT about converting at all.
I will not solve th
21 matches
Mail list logo