LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pandas

I used LabVIEW to create the GUI for to app I am working on and wrote a code in python for LabVIEW to call. I did some small tests to check if it was working before I wrote the code, but I had to import pandas and scipy while developing the code, and LV was working fine until I tried to import a .csv file in the python code. I'm just wondering if this is an installation problem or if the error is because I'm trying to read a .csv file in a python script called from labview.

 

jacobpew39_0-1626998131938.pngjacobpew39_1-1626998156105.png

I've tried 3.6, 3.6.3, and 3.6.8 and have had the same issue with all versions.

0 Kudos
Message 1 of 6
(3,439 Views)

Does labview work with pandas

0 Kudos
Message 2 of 6
(3,433 Views)

Have you tried performing some simple file I/O to test if there are any permissions errors or something like that? I wrote a simple function to test using the math package:

rwunderl_0-1627045276439.png

 

Perhaps try using a try-except block to see where the error is coming from.

 

This article shows an example of how to call the NumPy package. The most interesting thing here is that at the bottom it states, "This article does not guarantee all functions in the NumPy package are supported by LabVIEW Python Node." I wonder why...

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 3 of 6
(3,346 Views)

Yeah I have it to where it can perform simple opperations like importing a value from labview, create a dataframe, take the standard deviation using pandas, and export the std to labview.

The error comes when I try to import a .csv file into python. I'm hoping there is a work around, because I've been working on this project for almost a year and this is literally the last part.

0 Kudos
Message 4 of 6
(3,319 Views)

I don't know how to return a pandas dataframe via python node to LabView

 

but reading a csv via pandas within the python node doesn't throw any errors

 

path-pandas.png

 

0 Kudos
Message 5 of 6
(3,255 Views)

ok, there appears to be an issue with reading csv files with numpy's loadtxt within the python node - maybe this is related to the original topic

 

the following code generates a file.csv in the same directory as labview.vi and script.py -

further more the code then uses the python node to open this csv and return it as 2d array of strings

 

path-numpy.png

 

the python node spits out error 1672 - which is very generic

alexderjuengere_0-1627299288069.png

 

 

 

 

if the script.py is executed in a python IDE, it will execute successfully and return the array size

 

 

 

 


# actual function
import numpy as np
def return_csv(path😞
    x = np.loadtxt(path, delimiter=";"dtype="str")

    return x

# debug
import os
base = os.path.dirname(__file__)
path = (os.path.join(base, "file.csv"))

print(return_csv(path).shape)

 

(10, 2) 
0 Kudos
Message 6 of 6
(3,233 Views)