Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88371

Re: Using csv DictWriter - add a extra field

From Peter Otten <__peter__@web.de>
Subject Re: Using csv DictWriter - add a extra field
Date 2015-03-31 11:03 +0200
Organization None
References <a72cf80c-cb27-4ec2-bcf4-76f3b208a6d4@googlegroups.com> <mailman.363.1427790193.10327.python-list@python.org> <62ae3aca-dcc4-45be-ba2f-c575bb08b7b3@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.364.1427792631.10327.python-list@python.org> (permalink)

Show all headers | View raw


Victor Hooi wrote:

> Aha, yeah, I can add the connection_id as another field in the inner dict
> - the only drawback is that the data is duplicated twice. However, I
> suppose even if it's not elegant, it does work.

The elegance lies in its simplicity, so it's still my personal favourite.

> However, that ChainMap does look interesting =). And yes, I am actually
> using Python 3.x (mainly because of http://bugs.python.org/issue6641).
> 
> So if I understand correctly, I can just use ChainMap to join any
> arbitrary number of dicts together - it seems like the right solution
> here.
> 
> Are there any drawbacks to using ChainMap here? (Aside from needing Python
> 3.x).

As it introduces another level of indirection it costs a little time, but 
compared to the actual I/O that should be negligible. 

So no, if there is a drawback I don't see it.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Using csv DictWriter - add a extra field Victor Hooi <victorhooi@gmail.com> - 2015-03-30 21:47 -0700
  Re: Using csv DictWriter - add a extra field Peter Otten <__peter__@web.de> - 2015-03-31 10:22 +0200
    Re: Using csv DictWriter - add a extra field Victor Hooi <victorhooi@gmail.com> - 2015-03-31 01:41 -0700
      Re: Using csv DictWriter - add a extra field Peter Otten <__peter__@web.de> - 2015-03-31 11:03 +0200

csiph-web