Appending data to an excel sheet by python code

MRAB python at mrabarnett.plus.com
Sat Sep 14 13:06:27 EDT 2013


On 14/09/2013 12:33, Manoj Rout wrote:
> 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
>
It's a good idea to use raw string literals for file paths on
Windows. Alternatively, you could use forward slashes instead of
backslashes.

> file=open("C:\Workspace\WS2\P1\Dave\Generated\src\UART001\UART001_Conf.c","r")

Here you're reading the entire file:

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

Here you're trying to read the entire file again, but you're already
read to its end, so you'll now get an empty string:

> string=re.search(r'(?<=(.StopBit = UART_))\w+',file.read())
>
> print strings.group()
> print string.group()
>
What's 'workbook'? Don't you mean 'file'?

> workbook.close()
>
>
>
> Here if i will read only once then it is fine and not showing any error.But if i will do it for second time i.e.2nd string i have to search and print both of them,then it is showing error.
>
You haven't shown the traceback, so I have to guess what the error was.

> And one more problem how to append some data to an existing excel sheet by python code.
>
> so can u please help me on this problem.
>




More information about the Python-list mailing list