Hi,
how would I read from an Excel spreadsheet on non Windows platforms ?
I would use an external program call to some python code I would generate from OPL.
See example at
https://github.com/AlexFleischerParis/oplexcel/blob/main/readwithoutsheetread.modThe input is
Which generates python code
import pandas as pd
import xlrd
df=pd.read_excel('c:\\temp\\read2Darray.xls',sheet_name = 'Sheet1',skiprows = 0,nrows= 2,header=None,usecols = 'B:D')
print(df)
res = open("c:\\temp\\resexcel","w")
res.write("res=[")
res.write("\n")
for i, row in enumerate(df.values):
res.write("[")
for j in row:
if (j==j):
res.write(str(j))
res.write(",")
res.write("],")
res.write("\n")
res.write("];")
res.close()
which when run gives a .dat that you can use in OPL:
res=[
[5,6,7,],
[8,9,10,],
];
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
------------------------------