Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:text': 0.05; 'binary': 0.07; 'subject:file': 0.07; 'lawrence': 0.09; 'lines.': 0.09; 'newline': 0.09; 'subject:into': 0.09; 'python': 0.11; 'csv': 0.16; 'expects': 0.16; 'from:addr:timgolden.me.uk': 0.16; 'from:name:tim golden': 0.16; 'message-id:@timgolden.me.uk': 0.16; 'mode,': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'tjg': 0.16; 'wrote:': 0.18; 'module': 0.19; 'version.': 0.19; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'tend': 0.24; "i've": 0.25; 'handling': 0.26; 'header:In-Reply-To:1': 0.27; 'mode': 0.30; 'file': 0.32; 'open': 0.33; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'read': 0.60; 'blank': 0.60; 'from:addr:mail': 0.83; '2.7.': 0.84 Date: Thu, 06 Feb 2014 18:05:08 +0000 From: Tim Golden User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: parse a csv file into a text file References: <5c268845-003f-4e24-b27a-c89e9fbfcc6c@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391709913 news.xs4all.nl 2937 [2001:888:2000:d::a6]:49807 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65547 On 06/02/2014 17:40, Mark Lawrence wrote: > On 06/02/2014 14:02, Neil Cerutti wrote: >> >> You must open the file in binary mode, as that is what the csv >> module expects in Python 2.7. newline handling can be enscrewed >> if you forget. >> >> file = open('raw.csv', 'b') >> > > I've never opened a file in binary mode to read with the csv module > using any Python version. Where does it state that you must do this? > If you don't, you tend to get interleaved blank lines. (Presumably unless your .csv is using \n-only linefeeds). TJG