On Mon, 6 Sept 2021 at 01:13, Greg Ewing wrote:
>
> On 6/09/21 3:07 am, C. Titus Brown via Python-ideas wrote:
> > with csv.DictReader.open(filename) as r:
> > for row in r:
> >…
>
> You can do this now:
>
> from contextlib import closing
> with closing(csv.DictReader.open(filename)) a
On 6/09/21 3:07 am, C. Titus Brown via Python-ideas wrote:
with csv.DictReader.open(filename) as r:
for row in r:
…
You can do this now:
from contextlib import closing
with closing(csv.DictReader.open(filename)) as r:
...
IMO this is preferable than going around adding context m
On Sun, Sep 5, 2021 at 10:32 AM David Mertz, Ph.D.
wrote:
> Most Pandas read methods take either a path-like argument or a file-like
> argument, and figure out which it is by introspection when called.
> Actually, most of them even accept a URL-like argument as well
>
> I don't think this is a te
On Mon, Sep 6, 2021 at 9:37 AM Finn Mason wrote:
>
> Hello all,
>
> In Python 3.10 and 3.11, exception tracebacks are being greatly improved. I
> noticed that there's nothing related to a fairly common (in my personal
> experience) cryptic traceback relating to the `with` statement:
>
> >>> with
Hello all,
In Python 3.10 and 3.11, exception tracebacks are being greatly improved. I
noticed that there's nothing related to a fairly common (in my personal
experience) cryptic traceback relating to the `with` statement:
>>> with ContextManager as ctx:
... # do something with `ctx`
...
Trac
Most Pandas read methods take either a path-like argument or a file-like
argument, and figure out which it is by introspection when called.
Actually, most of them even accept a URL-like argument as well
I don't think this is a terrible approach. It doesn't make things quite as
explicit as the stan
> This would only be helpful when the CSV is on the disk but csv.reader()
> takes a file object so that it can used with anything like a socket for
> example. json.load() does the same thing.
>
There has been discussion about adding loading from a “path like” to the
JSON lib. See this list about t
> On 5 Sep 2021, at 17:07, C. Titus Brown via Python-ideas
> wrote:
>
> Hi all,
>
> the product of Sunday morning idle curiosity...
>
> I’ve been using the csv module a lot, and I’m wondering if there would be
> value in adding a standard mechanism for opening a CSV file (correctly) using
Seems nice, tarfile has a similar shortcut too. I do tend to reach for
pandas now whenever I can for csv processing
On Sun, 5 Sep 2021, 16:10 C. Titus Brown via Python-ideas, <
python-ideas@python.org> wrote:
> Hi all,
>
> the product of Sunday morning idle curiosity...
>
> I’ve been using the cs
Hi all,
the product of Sunday morning idle curiosity...
I’ve been using the csv module a lot, and I’m wondering if there would be value
in adding a standard mechanism for opening a CSV file (correctly) using a
context manager?
So, instead of
with open(filename, newline=“”) as fp:
r = csv.D
10 matches
Mail list logo