Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.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; 'insert': 0.05; 'column': 0.07; 'modified': 0.07; 'source.': 0.07; 'field)': 0.09; 'iterate': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rows': 0.09; 'csv': 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; 'wrote:': 0.18; 'example': 0.22; 'header:User-Agent:1': 0.23; 'source': 0.25; 'header:X -Complaints-To:1': 0.27; 'tried': 0.27; 'subject:list': 0.30; 'follows': 0.31; 'file': 0.32; 'figure': 0.32; 'open': 0.33; 'could': 0.34; 'advice': 0.35; 'but': 0.35; 'really': 0.36; "didn't": 0.36; 'thanks': 0.36; 'list': 0.37; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'new': 0.61; 'field': 0.63; 'here': 0.66; 'destination': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Write list to new column in existent csv Date: Fri, 17 Oct 2014 20:08:42 +0200 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p57bd845a.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1413569341 news.xs4all.nl 2950 [2001:888:2000:d::a6]:51273 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:79249 Tal Bar-Or wrote: > I am tryin to figure how to write a list i have as follows > To a a csv to for example the 3rd column , i am really got stacked here i > tried few codes with csv.writerow() but didn't got it work ,will really > appreciate if someone could help me with that Please advice Thanks Here's a sketch: Open the source file using a csv.reader(); open the destination file using a csv.writer(). Use zip() and a for-loop to iterate over the new column and the rows in the source. Insert the new field into the source row, e. g. row.insert(3, field) Use writerow() to write the modified row.