ValueError: invalid path type trying to set file path

61 Views Asked by At

I'm trying to built an automation using (external) python to pull data from excel sheets and fill them into OriginPro (OriginLabs), do curve fittings and pull specific values from the analysis and store them in another excel sheet. Right at the beginning, when I run the script I get an ValueError: Invalid path type trying to set the origin file path.

#Pull Data from excel sheets
#Put data in table in originpro
#create scatter diagram from sheet data
#analyse/fit scatter diagram with gauss fit
#pull data from analysis: xc,r2 and height
#save file (create new folder in nessecary)



#to be able to interact with originpro
import originpro as op

#set origin file path
origin_exe_path = r'C:\Program Files\OriginLab\Origin2023b\Origin64.exe'


# Open Origin 
op.oexec(f)

# Set Excel file path
excel_file_path = op.path(r'C:\Users\Kristjan\Desktop\M11+P32.xlsx')


#Create new worksheet in originpro
wks = op.new_sheet()
print ('worksheet created')


#Create data connector object
dc = op.Connector(wks, dctype='Excel', keep_DC=True)

# Access data connector settings - so i can use different setting 
ss = dc.settings()


#Headerlines to column label
labels = ss['labels']
labels[op.attrib_key('Use')] = '1'
labels['longname'] = 'm/z'
labels['unit'] = 'none'


#Setting for partial import
partial = ss['partial']
partial[op.attrib_key('Use')] = '1'
partial['col'] = '6'
partial['row'] = '8:21'

#Import the second spreadsheet 'expt2'
dc.imp(f, sel='expt2')

I tried setting an raw string since \Users is sometimes problematic I read. I also separated the original function f = op.path('e')+r'Samples\Import and Export\Partial Import.xlsx'.

0

There are 0 best solutions below