It's possible with xlsxwriter to save variables to existing excel files and read them after, though the problem is that the variables are stored as strings in my excel file.
Let's say I have a list of many different variables with various types (pd.datetimerange, pd.df, np.arrays, etc.), if I save them to the excel file the variable type would be lost.
Also the Python script is called from my Excel file so I can't change anything in it without writing a VBA script. Which would temporarily close my workbook, dump the chars (with say pickle strings) and reopen it.
Is it possible to retrieve the types from the excel file without writing a parsing function first (which would take the excel string and yield me with the equivalent variable type)?
As per your comment, you can get
eval
to correctly process the symbols that are local to some module by passing the appropriate dict of locals intoeval
, along with your string. Here's a workable solution:Output:
As a Responsible Person, it is also my duty to warn you that using
eval
for your application is ridiculously unsafe. There are many discussions of the dangers ofeval
, and none of them suggest there's a way to completely mitigate those dangers. Be careful if you choose to use this code.