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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'suppose': 0.07; 'elegant,': 0.09; 'here?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:extra': 0.09; 'yeah,': 0.09; 'python': 0.11; '(mainly': 0.16; 'dict': 0.16; 'introduces': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'simplicity,': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'header :User-Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'url:bugs': 0.29; 'compared': 0.30; 'work.': 0.31; '3.x': 0.31; 'lies': 0.31; 'another': 0.32; 'url:python': 0.33; 'actual': 0.34; 'no,': 0.35; 'but': 0.35; 'add': 0.35; 'there': 0.35; 'url:org': 0.36; 'should': 0.36; 'level': 0.37; 'to:addr:python-list': 0.38; 'little': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'costs': 0.63; 'personal': 0.63; 'field': 0.63; 'needing': 0.65; 'subject:Using': 0.84; 'victor': 0.84; 'subject:add': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Using csv DictWriter - add a extra field
Date Tue, 31 Mar 2015 11:03:36 +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>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p57bd93cd.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.364.1427792631.10327.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1427792631 news.xs4all.nl 2941 [2001:888:2000:d::a6]:41859
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:88371

Show key headers only | 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