T O P I C R E V I E W |
jan.oechsler |
Posted - 02/16/2021 : 02:51:56 AM Is it possible to access the data connector functionality via python?
I have some files which need some pre processing (unzipping, interpreting as XML etc) before they could be transfered to origin. What would be the best way to tackle this? |
7 L A T E S T R E P L I E S (Newest First) |
jan.oechsler |
Posted - 02/16/2021 : 4:27:58 PM Thats great news.
Just spitballing here, but couldnt you just write a python wrapper (or better, add it to the originpro package) that just wraps all the necessary Origin C functions? That way the framework can stay as it is, but you can still write python only scripts for connectors?
I personally love python, especially for data management, so maybe I'm a bit biased here.
However until then, being able to write custom connectors using Origin C and calling python from that would be already really helpful.
Keep up the good work and great support! I left Origin in 2016 for python and am right now coming back, only because of the newly implemented python support! |
cpyang |
Posted - 02/16/2021 : 2:06:55 PM I am afraid you will need to use Import Filter for now.
General support for user made connector is something we will work on, as the framework is entirely Origin C based, so it can be done already but we have not documented it. Python can also be easily called from OC, so in principle this can be done, but since we are going to release Origin 2021b in April, not enough time for this upcoming version, this will likely be Origin 2022 in Oct.
If you would like an entirely Python connector without Origin C shell, then we need to do more work.
CP
|
jan.oechsler |
Posted - 02/16/2021 : 1:15:44 PM Thanks. Good to see that you're already onto this bug!
However: quote: So my real question is: how can i create a custom data connector (python or not)? Under Data|Connect to File|Add new... it only shows the App-Center with some additional predefined connectors. Is it possible to add a custom one here?
What about this? Besides adding stuff via the import filter, will there be an option to create custom Connectors? |
cpyang |
Posted - 02/16/2021 : 10:14:44 AM Looks like there is a bug with using Python in Import Filter, and we can see it, it works in the initial import but failed when reopen OPJU to import again. Tracking id is ORG-22488 P2, and we will fix this shortly.
Thanks for the report.
CP
|
Chris D |
Posted - 02/16/2021 : 10:13:11 AM Hi Jan,
I sent you an email via our new ticket system about fixing the issue in the next beta release of Origin 2021b.
Thanks, Chris Drozdowski Originlab Technical Support
|
jan.oechsler |
Posted - 02/16/2021 : 06:22:07 AM A custom filetype, one that is neither in the pre installed list nor in the App-Center. (for example .brml which is a set of xml files in a disguised zip).
I already wrote an import filter which works fine for importing the data into origin using python (following this post: http://blog.originlab.com/creating-a-python-based-import-filter-with-origin-2021)
But i would like to be able to use the data connectors for this, to not have the data saved into origin file (in order to not blow the size up to much) but adding it as a dependency.
In the mean time I tried the following:
Create a new book Then: Data|Connect to File|Import Filter In the following dialog I open my file (.brml) Then a dialog pops up where it shows my already existing "import filter" associated with that file type.
Great. It runs the python code (i know because i can see my log prints in the Labtalk console) and the data connector icon in the top left of the workbook lights up in green.
However when I then click the connector icon and then hit "import" it doesnt rerun my python file (i cannot see any log prints in the labtalk console), it just resets the work sheet and the the connector turns "yellow".
Ithink this happens because there is no connector associated with my filetype and it doesnt "know" that the import script I have provided works for that.
So my real question is: how can i create a custom data connector (python or not)? Under Data|Connect to File|Add new... it only shows the App-Center with some additional predefined connectors. Is it possible to add a custom one here?
Cheers Jan
|
cpyang |
Posted - 02/16/2021 : 05:41:30 AM What type of files?
Currently, from_file supports Text files and Excel files and CSV and Excel connector are used. You can choose to keep the connector, as default is to remove the connector, see
https://www.originlab.com/python/doc/originpro/classoriginpro_1_1worksheet_1_1_w_sheet.html#af54268e5d8cb8799ed8a4c71e5bc051c
CP
|