Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90069
| X-FeedAbuse | http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63 |
|---|---|
| Path | csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!news.muarf.org!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
| Return-Path | <python.list@tim.thechases.com> |
| 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; 'puts': 0.07; 'tries': 0.07; 'string': 0.09; '*is*': 0.09; 'string;': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; ':-(': 0.16; 'character:': 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; 'untouched.': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'file,': 0.19; 'value.': 0.19; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'text,': 0.24; 'regardless': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'least': 0.26; 'excel': 0.26; 'skip:" 20': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'tim': 0.29; "doesn't": 0.30; 'subject:list': 0.30; 'chase': 0.31; 'skip:q 20': 0.31; "they'll": 0.31; 'though.': 0.31; 'file': 0.32; 'could': 0.34; 'but': 0.35; 'described': 0.36; 'charset:us-ascii': 0.36; 'received:10': 0.37; 'pm,': 0.38; 'rather': 0.38; 'quote': 0.39; 'ian': 0.60; 'tell': 0.60; 'hope': 0.61; 'field.': 0.61; 'happen': 0.63; 'to:addr:gmail.com': 0.65; 'number:': 0.66; 'content,': 0.68; '2015': 0.84; 'hand.': 0.84 |
| 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 | 1430937391241:1647175928 |
| X-MC-Ingress-Time | 1430937391241 |
| Date | Wed, 6 May 2015 13:37:12 -0500 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | Ian Kelly <ian.g.kelly@gmail.com> |
| Cc | Python <python-list@python.org> |
| Subject | Re: Writing list of dictionaries to CSV |
| In-Reply-To | <CALwzid=yoTxetHRuVDaDnCW9ASXVruF02gE2CZgsszJ6=3YxWQ@mail.gmail.com> |
| References | <5bd0afb3-d2d4-469f-be39-5869f01adc92@googlegroups.com> <072badd6-0542-468a-99bd-cc3a4ffc7156@googlegroups.com> <554A58B4.80700@mrabarnett.plus.com> <20150506132255.510c2eec@bigbox.christie.dr> <CALwzid=yoTxetHRuVDaDnCW9ASXVruF02gE2CZgsszJ6=3YxWQ@mail.gmail.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 <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.186.1430937980.12865.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1430937980 news.xs4all.nl 2832 [2001:888:2000:d::a6]:60421 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90069 |
Show key headers only | View raw
On 2015-05-06 12:27, Ian Kelly wrote: > On Wed, May 6, 2015 at 12:22 PM, Tim Chase > <python.list@tim.thechases.com> wrote: > > 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. > > Quoting a value in csv doesn't mean it's a string; it just means > that it's a single field. > > You *can* force Excel to treat a value as a string by prefixing it > with an apostrophe, though. Excel takes the apostrophe in the CSV file and puts it in the content, rather than stripping it as an escape/formatting character: c:\temp> type test.csv "'Mar 2015",Mar 2015,3,2015 "Apr 2015",Apr 2015,4,2015 "2015-12",2015-12,12,2015 c:\temp> start test.csv A1 has the unformatted text, but includes the apostrophe in the value. B1, A2, and B2 get munged like the OP described to the form "Apr-15". The items in row #3 come through untouched. At least on Excel 2003 on WinXP which is what I happen to have on hand. -tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Writing list of dictionaries to CSV Kashif Rana <kashifrana84@gmail.com> - 2015-05-05 10:09 -0700
Re: Writing list of dictionaries to CSV MRAB <python@mrabarnett.plus.com> - 2015-05-05 19:11 +0100
Re: Writing list of dictionaries to CSV Skip Montanaro <skip.montanaro@gmail.com> - 2015-05-05 13:25 -0500
Re: Writing list of dictionaries to CSV Cecil Westerhof <Cecil@decebal.nl> - 2015-05-05 20:44 +0200
Re: Writing list of dictionaries to CSV Matthew Ruffalo <mmr15@case.edu> - 2015-05-05 15:43 -0400
Re: Writing list of dictionaries to CSV Tim Chase <python.list@tim.thechases.com> - 2015-05-05 12:34 -0500
Re: Writing list of dictionaries to CSV Kashif Rana <kashifrana84@gmail.com> - 2015-05-05 22:32 -0700
Re: Writing list of dictionaries to CSV Chris Angelico <rosuav@gmail.com> - 2015-05-06 16:34 +1000
Re: Writing list of dictionaries to CSV Cecil Westerhof <Cecil@decebal.nl> - 2015-05-06 08:50 +0200
Re: Writing list of dictionaries to CSV Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-05-06 09:14 -0400
Re: Writing list of dictionaries to CSV MRAB <python@mrabarnett.plus.com> - 2015-05-06 19:08 +0100
Re: Writing list of dictionaries to CSV Tim Chase <python.list@tim.thechases.com> - 2015-05-06 13:22 -0500
Re: Writing list of dictionaries to CSV Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-06 12:27 -0600
Re: Writing list of dictionaries to CSV Tim Chase <python.list@tim.thechases.com> - 2015-05-06 13:37 -0500
Re: Writing list of dictionaries to CSV Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-06 23:31 +0000
Re: Writing list of dictionaries to CSV Tim Chase <python.list@tim.thechases.com> - 2015-05-06 20:22 -0500
Re: Writing list of dictionaries to CSV Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-05-07 01:55 +0000
Re: Writing list of dictionaries to CSV [correction] Tim Chase <python.list@tim.thechases.com> - 2015-05-06 20:52 -0500
csiph-web