I am using Embedded Python.
I was unsing the command window, script window and also Python-console. All throw the same error, but in the script wondow is got a slightly other string (ok, it is just an other font, when i copy the output to the same texteditor, the output is the same...)
I changed the script to use OriginExt and it is running with spyder (ide).
When i try the same script from Origin with the following command, it fails with the same error.
run -pyf "test_import_ext.py"
File "C:\Users\was2liz\Documents\OriginLab\User Files\test_import_ext.py", line 39, in import_ess_file
file = open(filename, 'r')
FileNotFoundError: [Errno 2] No such file or directory: 'S:/Q-Bereiche/Transfer/Prüfstände/F51 CRIN4 ESS/VA 2020/INV200351/ST1/Inj_20213 ST1-1.TXT'
Embedded Python: running with Origin failed.
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 14:15:23 2020
@author: Stefan
"""
import PyOrigin # Origin Funktionen
class ESS_Import():
DELIMITER = ';'
HEADER_LINES = 2
SPACES = 2
INJ_PRAEFIX = "Messung 00 Inj.Nr.: "
INJ_LENGTH = 5
DATE_START = len(INJ_PRAEFIX) + INJ_LENGTH + SPACES
DATE_LEN = 10
TIME_START = DATE_START + DATE_LEN + SPACES
TIME_LEN = 8
def __init__(self):
self.import_ess_file("S:\Q-Bereiche\Transfer\Prüfstände\F51 CRIN4 ESS\VA 2020\INV200351\ST1\Inj_20213 ST1-1.TXT")
def import_ess_file(self, filename):
data = []
filename = filename.replace("\\", "/")
file = open(filename, 'r')
lines = file.readlines()
for line in lines:
innerlist = line.split(self.DELIMITER)
data.append(innerlist)
self.data = data
self.extract_data()
self.check_data()
def check_data(self):
pass
def extract_data(self):
pass
def init_workbooks(e):
mBookName = "ST1"
messungen = PyOrigin.Pages(mBookName)
if messungen == None:
messungen = PyOrigin.CreatePage(PyOrigin.PGTYPE_WKS, mBookName,
'Origin', 1)
cntSheets = PyOrigin.Pages(mBookName).Layers.GetCount()
for books in range(cntSheets, e.etc_count):
PyOrigin.Pages(mBookName).AddLayer()
for books in range(0, len(PyOrigin.Pages(mBookName))):
messungen.Layers(books).SetName(f"KL_{books+1}")
def main():
e = ESS_Import()
init_workbooks(e)
# TODO
pass
if __name__ == "__main__":
main()
With originExt, started with Spyder (IDE), working fine :-)
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 14:15:23 2020
@author: Stefan
"""
#import PyOrigin # Origin Funktionen
import OriginExt as O
class ESS_Import():
DELIMITER = ';'
HEADER_LINES = 2
SPACES = 2
INJ_PRAEFIX = "Messung 00 Inj.Nr.: "
INJ_LENGTH = 5
DATE_START = len(INJ_PRAEFIX) + INJ_LENGTH + SPACES
DATE_LEN = 10
TIME_START = DATE_START + DATE_LEN + SPACES
TIME_LEN = 8
def __init__(self):
self.import_ess_file("S:\Q-Bereiche\Transfer\Prüfstände\F51 CRIN4 ESS\VA 2020\INV200351\ST1\Inj_20213 ST1-1.TXT")
def import_ess_file(self, filename):
data = []
filename = filename.replace("\\", "/")
file = open(filename, 'r')
lines = file.readlines()
for line in lines:
innerlist = line.split(self.DELIMITER)
data.append(innerlist)
self.data = data
self.extract_data()
self.check_data()
def check_data(self):
pass
def extract_data(self):
pass
def init_workbooks(e):
mBookName = "ST1"
Oapp = O.Application()
messungen = Oapp.Pages(mBookName)
if messungen == None:
messungen = Oapp.CreatePage(2, mBookName,
'Origin', 1)
cntSheets = Oapp.Pages(mBookName).Layers.GetCount()
for books in range(cntSheets, e.etc_count):
Oapp.Pages(mBookName).AddLayer()
for books in range(0, len(Oapp.Pages(mBookName))):
Oapp.Pages(mBookName).Layers(books).SetName(f"KL_{books+1}")
Oapp.Save(r'c:\temp\test_1.opju')
Oapp.Exit()
def main():
e = ESS_Import()
init_workbooks(e)
# TODO
pass
if __name__ == "__main__":
main()