Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'tries': 0.07; '*is*': 0.09; 'string;': 0.09; '-tkc': 0.16; ':-(': 0.16; 'csv': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'quoted': 0.16; 'subject:CSV': 0.16; 'subject:Writing': 0.16; 'subject:dictionaries': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'tests': 0.22; 'regardless': 0.24; 'looks': 0.24; 'source': 0.25; 'excel': 0.26; 'values': 0.27; 'header:In-Reply- To:1': 0.27; 'tried': 0.27; 'subject:list': 0.30; 'skip:q 20': 0.31; "they'll": 0.31; 'could': 0.34; 'charset:us-ascii': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'quote': 0.39; 'to:addr:python.org': 0.39; 'tell': 0.60; 'hope': 0.61; 'number:': 0.66 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1430936531508:1692540544 X-MC-Ingress-Time: 1430936531508 Date: Wed, 6 May 2015 13:22:55 -0500 From: Tim Chase To: python-list@python.org Subject: Re: Writing list of dictionaries to CSV In-Reply-To: <554A58B4.80700@mrabarnett.plus.com> References: <5bd0afb3-d2d4-469f-be39-5869f01adc92@googlegroups.com> <072badd6-0542-468a-99bd-cc3a4ffc7156@googlegroups.com> <554A58B4.80700@mrabarnett.plus.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AuthUser: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430936543 news.xs4all.nl 2879 [2001:888:2000:d::a6]:53964 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90067 On 2015-05-06 19:08, MRAB wrote: > You could tell it to quote any value that's not a number: > > w = csv.DictWriter(f, pol_keys, > quoting=csv.QUOTE_NONNUMERIC) > > It looks like all of the values you have are strings, so they'll > all be quoted. > > I would hope that Excel will then treat it as a string; it would be > stupid if it didn't! :-) Sadly, Excel *is* that stupid based on the tests I tried just now. :-( Regardless of whether "Mar 2015" is quoted or unquoted in the source CSV file, Excel tries to outwit you and mangles the presentation. -tkc