The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Python
 Package Installation is easier in 2020b

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
cpyang Posted - 05/27/2020 : 6:11:18 PM
You can easily install Python packages with Origin2020b, just run InstallPythonPackages from the Script Window, for example to run the follow Excel export code, need to install xlsxwriter, then just open Script Window and type
InstallPythonPackages(0,xlsxwriter)
and hit enter.

To try this code, open Code Builder, new a py file in UFF, like call it test1.py, then paste the code below, save the file, and from Script Window type "run -pyf test1.py". This code assume you have a worksheet to export with some data:


import PyOrigin
import xlsxwriter
 
wks =  PyOrigin.ActiveLayer()
file = PyOrigin.GetPath(PyOrigin.PATHTYPE_USER)+'Data.xlsx'
workbook = xlsxwriter.Workbook(file)
worksheet = workbook.add_worksheet()
bold = workbook.add_format({'bold': 1})
for i, col in enumerate(wks):
	header = col.GetLongName();
	unit = col.GetUnits();
	data = col.GetData()
	worksheet.write(0, i, header, bold)
	worksheet.write(1, i, unit, bold)
	worksheet.write_column(2, i, data)

workbook.close()


There is also an App for installing packages, see

https://www.originlab.com/fileExchange/details.aspx?fid=414

Please note that if you had error with Python before you install a package, you need to restart Origin.

CP
3   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 05/31/2020 : 07:05:56 AM
Thanks Castiel,

I updated my example above, this indeed allow the same code to work in 2020b and going forward where we fixed the bug that list in OriginObjects not accessible as properties.

CP
Castiel Posted - 05/31/2020 : 06:51:31 AM
quote:
Originally posted by cpyang



#2021 will be enumerate(wks.Columns)
for i, col in enumerate(wks.Columns()):




Alternatively, this also works:
#2021 will be enumerate(wks.Columns)
#for i, col in enumerate(wks.Columns())
for i, col in enumerate(wks):

                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************
nick_n Posted - 05/28/2020 : 10:12:02 PM
Hi,
Thank you very much! With App it is so easy now. I guess, both InstallPythonPackages and App should be mentioned in help files. Best regards,

Nikolay

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000