03-16-2020 03:50 PM
I try to read an Excel file (.xlsx) and return an 2D Array of string to Labview.
To verify if I am able to correctly read the file: I read the file and write a CSV file from the original Excel file - this part works even if I have an error (Python returned the following error: <class 'SystemError'> ..\Objects\listobject.c:189: bad argument to internal function).
The script is:
import pandas as pd
def MyFunction_Excel(path1, path2):
dfs = pd.read_excel(path1)
dfs.to_csv(path2)
return dfs
I am not able to return the 2D Array. What I am doing wrong?
JM
03-16-2020 04:00 PM
What exactly is the Python script doing besides reading the Excel file? Why not read the file directly in LabVIEW and process it there?
03-16-2020 04:09 PM
I actually utilize the report generation toolkit to read this type of file, but it is slow. I hope to accelarate the process with python.
JM
03-16-2020 04:14 PM
What format is the file saved in? Is it an Excel file or is it stored as a CSV file? Reading a CSV file is quite fast. If it is in an Excel format, I'm not sure Python will be much faster.
03-16-2020 04:16 PM
It is Excel file (*.xlsx).
JM
03-19-2020 09:20 AM
I recommend that you attach a sample Excel file that is "slow to read". If it is a very large Excel file, Excel, itself, might be slow to read it. It might be "complex", i.e. have many Worksheets, be full of Images, Graphs, and other features, and there may be suggestions for "pre-processing" (such as reading the whole file and "exporting" selected Worksheets).
Bob Schor
03-19-2020 10:26 AM
As for returning the 2D array you might need to 'reserve' array memory be initializing the array before sending it to Python.
/Y