Ask Your Question
0

Dyntools Overwrite Excel Sheet

asked 2018-03-21 19:44:01 -0600

camerond12 gravatar image

Hello,

I am using dyntools to output data to excel.

dyntools.CHNF.xlsout(xlsresult, channels=[], show=False, xlsfile=xlsoutput, outfile=outfile, overwritesheet = True)

This is the code I am using, I believe that overwritesheet = True should overwite sheet1 every time I run the script.

I currently need to delete the old excel sheet every time I re run my script or else the excel workbook will create new sheets of the same data, which causes the file to become huge.

What should I do?

Thanks

edit retag flag offensive close merge delete

5 answers

Sort by » oldest newest most voted
0

answered 2019-05-10 11:18:12 -0600

jconto gravatar image

In v.33.12, the overwritesheet setting works as expected. The following is the code I used:

   try: 
     chnfobj.xlsout(channels=mychannels, 
                    outfile=filei,
                    xlsfile=XLSfile,
                    sheet=sheetname,
                    overwritesheet = True,
                    show=False 
                    )
   except:
     print '\n ERROR: Exporting Channels to %s Excel file, sheet %s failed.'%(XLSfile,sheetname)
edit flag offensive delete link more
0

answered 2019-05-10 07:51:21 -0600

drsgao gravatar image

I found that even if you set overwritesheet = True, it does not always overwrite it. In fact, I have encountered multiple cases where I wanted it to be overwritten but new sheets were added to the workbook instead. Could be a bug.

edit flag offensive delete link more
0

answered 2018-08-17 13:57:12 -0600

Juan gravatar image

I have the following problem Dyntools does not extract data from file out

** LINES PER PAGE for FILE OUTPUT set to 60

Output completed Traceback (most recent call last): File "C:\0-C\0-Simulaciones\Caso\Simulación.py", line 227, in <module> datosexcel = dyntools.CHNF(archivoout + '.out') File ".\dyntools.py", line 1023, in init File ".\dyntools.py", line 351, in outextractdata File ".\dyntools.py", line 321, in outextractid

Couldn't open Python file: C:\0-C\0-Simulaciones\Caso\Simulación.py

edit flag offensive delete link more

Comments

check my post at "Multi-Threading using xlsout"

jconto gravatar imagejconto ( 2018-08-17 17:58:09 -0600 )edit

HI, Thanks

Juan gravatar imageJuan ( 2018-08-21 09:08:04 -0600 )edit

Hello, I don't know how to solve this problem, but my opinion is that you should never use orthographic accent in Python even in comments or files names.

SAE_2016 gravatar imageSAE_2016 ( 2018-09-07 09:14:55 -0600 )edit
0

answered 2018-03-28 19:42:35 -0600

haveityourwa gravatar image

if you also have lots of sheets you could delete a folder and remake it instead of each sheet,

if os.path.exists(PathDir + r"\sheets"):
    shutil.rmtree(PathDir + r"\sheets")
    os.makedirs(PathDir + r"\sheets")

Tried this as a comment but no formatting was available. Sorry if you got spammed with notifications of me changing the comment a bunch

edit flag offensive delete link more
0

answered 2018-03-22 02:20:05 -0600

camerond12 gravatar image

I think that this overwritesheet = true option will overwrite latest sheet if it is called more than once during simulation.

In my case, I am re running the script rather than using the dyntools command more than once in the same script.

To overcome this, I check for and delete existing excel file in directory by adding the following code just before using dyntools.CHNF.xlsout(..)

if os.path.exists(xlsoutput):
   try:
      os.remove(xlsoutput)
   except WindowsError:
      print 'file is open'
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2018-03-21 19:44:01 -0600

Seen: 900 times

Last updated: May 10 '19