Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54170
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: Appending data to an excel sheet by python code |
| Date | 2013-09-14 13:22 -0400 |
| Organization | IISS Elusive Unicorn |
| References | <87454429-bd36-44b2-bef1-055d976c16ae@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.378.1379179382.5461.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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