Ask Your Question
0

Export all channels of a .out (Dyntools) to excel file

asked 2019-02-21 03:49:36 -0500

L0r3als gravatar image

updated 2019-02-25 05:16:29 -0500

Hello, I am writing because I have around 50 .out files. Inside each simulation, I have several channels. I would like to export all of them into an excel file or a txt. I tried to export with a function named " dyntools" and also with "excelpy" but it does not work. Someone knows, How could create an excel file? Could I create a TXT instead and EXCEL file with all the channels info to avoid the overflow error? Could I do a txt file with all the channels without created a graph in python?

    import excelpy
    import dyntools

# LF process

# Channels identification

#LVRT TEST: out_file11

#PROBLEM: EXPORT ALL OUT CHANNELS TO AN EXCEL/TXT FILE

According to the information which I read in the forum, I did several tests in order to find the best way for exporting the .out channels to and text or excel file. However, I have not any psse reply, The excel is not created and no answer is written in the alert/progress output file. After doing several tests, the problem was in the definition of the Output file it was fixed thanks to the post "Using api "pssplot.channelfileexcelexport()" rasise error" , I write the solution and the tests which I did:

SOLUTION*

In the dynamic simulation test the .out should be defined:

psspy.set_chnfil_type(0)  
psspy.strt_2([0,1],out_file11)
psspy.run(0,3.0,L1,L2,L3)


#############=======================TEST 01 ================================

#out_file11 = 'case5_1.out'
txt_file='Case5_1.xlsx'
out_file11 = os.path.join(Root,'case5_1.out')
# txt_file= os.path.join(Root,'Case5_1.xlsx')
#pn, x = os.path.splitext(out_file11)


out_list=[]
# out_list.append.os.path.join(Root,'case5_1.out')
out_list = [out_file11]


#####FOUR OPTIONS

chnfobj = dyntools.CHNF(out_list,0) 
#chnfobj = dyntools.CHNF(out_file11,0) 
#chnfobj = dyntools.CHNF(out_file11,outvrsn=0) 
#chnfobj = dyntools.CHNF(out_list,outvrsn=0) 

##### OPTIONS #############

#chnfobj.xlsout(channels=[1,4], show=true, xlsfile=pn, sheet ='', overwritesheet=True)
chnfobj.xlsout(channels=[1,4], show=True, xlsfile=txt_file, sheet ='', overwritesheet=True)
#chnfobj.xlsout(channels=[1,4], show=True, xlsfile=txt_file, outfile='case5_1.out', sheet ='', overwritesheet=True)
#chnfobj.xlsout(outfile=out_file11,channels=[1,4], show = True, xlsfile=txt_file)

#############=======================TEST 02================================

# Root=os.getcwd()
# #out_file11 = 'case5_1.out'
# #txt_file='Case5_1.xlsx'
# out_file11 = os.path.join(Root,'case5_1.out')
# #txt_file=os.path.join(Root,'Case5_1.xlsx')

#chnfobj = dyntools.CHNF(out_list,0) 
# #chnfobj = dyntools.CHNF(out_file11,0) 
# #chnfobj = dyntools.CHNF(out_file11,outvrsn=0) 
# #chnfobj = dyntools.CHNF(out_list,outvrsn=0) 


# short_title, chanid, chandata = chnfobj.get_data()
# xl = excelpy.workbook(xlsfile='Case5_1.xlsx', mode='w')
# xl.set_range(1, 'a', [short_title])
# xl.save()
# xl.close()

#############=======================TEST 03================================

######====================Test_03.A===============
# # import win32com
# #xl = win32com.client.Dispatch("Excel.Application")
# #xl.DisplayAlerts = False

######=======================Test_03.B===============
# xl = excelpy.workbook(xlsfile, mode='w')

# name='case5.1';

# outfile = dyntools.CHNF(name+'.out')
# shorttitle, chaniddict, chandatadict = outfile.getdata()
# xlsfile=name+'.xlsx';
# xl = excelpy.workbook(xlsfile, mode='w')
# outfile.xlsout(sheet=name,overwritesheet=True)
# xl.save();
# xl.close()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-02-21 11:27:31 -0500

jconto gravatar image

to save channels directly to excel do the following [review functions available to CHNF by getting help from the module itself, check the forum about it):

outlst     = [outfile1]
try:
        chnf = dyntools.CHNF(outlst,0)
except:
        chnf = dyntools.CHNF(outlst,outvrsn=0)
chnf.xlsout(channels=[1,4,11,12])
edit flag offensive delete link more

Comments

I followed your advice, but now PSSe told me --> Error - Reading channel data error. I re-made the code in the post, but I PSSe does not achieve to read the out_file. Do you know what could it is happen?

L0r3als gravatar imageL0r3als ( 2019-02-22 04:14:03 -0500 )edit

Try the option: chnf = dyntools.CHNF(outlst,0)

jconto gravatar imagejconto ( 2019-02-22 13:42:16 -0500 )edit

Finally, the problem was in the definition of the .out file, I will write the solution. Thank you!!

L0r3als gravatar imageL0r3als ( 2019-02-25 05:05:46 -0500 )edit

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

Stats

Asked: 2019-02-21 03:49:36 -0500

Seen: 2,621 times

Last updated: Feb 25 '19