Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54170

Re: Appending data to an excel sheet by python code

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'subject:code': 0.07; 'string': 0.09; '"r"': 0.09; 'append': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:> 40': 0.09; 'python': 0.11; 'windows': 0.15; 'binary,': 0.16; 'message- id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:python': 0.16; 'sat,': 0.16; 'code.': 0.18; '(the': 0.22; 'command': 0.22; 'memory': 0.22; 'shell': 0.22; 'dll': 0.24; 'url:home': 0.24; 'file.': 0.24; '(or': 0.24; 'pass': 0.26; 'excel': 0.26; 'header:X-Complaints- To:1': 0.27; 'xml': 0.29; 'specified': 0.30; '(which': 0.31; 'code': 0.31; 'ctypes': 0.31; 'directly,': 0.31; 'libraries': 0.31; 'sep': 0.31; 'file': 0.32; 'maybe': 0.34; 'could': 0.34; 'problem': 0.35; 'basic': 0.35; 'there': 0.35; 'subject:data': 0.36; 'charset:us-ascii': 0.36; 'similar': 0.36; 'received:76': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'how': 0.40; 'read': 0.60; 'office': 0.60; 'first': 0.61; 'box,': 0.64; 'more': 0.64; 'here': 0.66; 'between': 0.67; 'calls,': 0.84; 'functions)': 0.84; 'subject:Appending': 0.84; 'navigate': 0.91; 'safety,': 0.91; 'sheet': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Appending data to an excel sheet by python code
Date Sat, 14 Sep 2013 13:22:59 -0400
Organization IISS Elusive Unicorn
References <87454429-bd36-44b2-bef1-055d976c16ae@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-249-17-94.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.378.1379179382.5461.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1379179382 news.xs4all.nl 15928 [2001:888:2000:d::a6]:49115
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:54170

Show key headers only | View raw


On Sat, 14 Sep 2013 04:33:42 -0700 (PDT), Manoj Rout
<manojrout70@gmail.com> declaimed the following:

>hi
>  i want to append some data to an existing excel sheet by reading from  file.But here i am facing 2 problem.first is when i am reading from file.
>
>
>import re
>
>file=open("C:\Workspace\WS2\P1\Dave\Generated\src\UART001\UART001_Conf.c","r")

	For safety, it is better to work with / rather than \ (the only time
you must have the \ in Windows is when sending the string to a command
shell -- os.system and similar functions)

>strings=re.search(r'(?<=(.Mode = UART_))\w+',file.read())

	You've just read the entire file and are now at EOF

>string=re.search(r'(?<=(.StopBit = UART_))\w+',file.read())
>
... so there is nothing left to read here.

	Either read the file into memory first and pass the string to both re
calls, or rewind the file (which may require closing/opening since you
specified "r" mode) between the re calls

>And one more problem how to append some data to an existing excel sheet by python code.
>

	Your best chances are to use libraries designed to access Excel files
(consider, Office XP Excel files are some crytic binary, while Office 2010
Excel files are zipped XML -- your code won't work on both forms).

	If you are on a Windows box, you could use ctypes (or maybe the win32
packages) to access the Excel DLL directly, and navigate just like you
would in an Excel "macro" (visual basic for applications).
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Appending data to an excel sheet by python code Manoj Rout <manojrout70@gmail.com> - 2013-09-14 04:33 -0700
  Re: Appending data to an excel sheet by python code MRAB <python@mrabarnett.plus.com> - 2013-09-14 18:06 +0100
  Re: Appending data to an excel sheet by python code Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-09-14 13:22 -0400
  Re: Appending data to an excel sheet by python code petmertens@gmail.com - 2013-09-14 10:28 -0700

csiph-web