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)?
str
and usingeval(str)
when re-opening the file may be a solution, i.e.: saving:x = '[123,456]'
opening:eval(x)
– Arrangex = "[123,DatetimeIndex(['2018-12-04','2018-12-05', '2018-12-06'],dtype='datetime64[ns]', freq='D')]"
. Theneval(x)
would yield an error name DatetimeIndex not defined (as it's a pandas variable type)... – Awrypickle
and storing it as a string in a cell. Painful just to think about it. – Tolidine