adamreeve / npTDMS

NumPy based Python module for reading TDMS files produced by LabView

Home Page:http://nptdms.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Printing the values of all tdms files in the same directory using the for loop in python

adityabhandwalkar opened this issue · comments

Discussed in #285

Originally posted by adityabhandwalkar October 17, 2022
I have a folder abc where I store my tdms files and I extract the data from those files using the the following function in python, now the problem is each time I run my main program I need to change the file number in the main so that I can run it, What I would like to do is that making changes into the load function and it will keep loop in same directory and print different values of files, lets say in abc I have file1.tdms, file2.tdms,... each time it should be printing values of different file in that folder abc

class loader():
    def load(self, path):

        
        tdms_file = TdmsFile.read(path)
        df = tdms_file.as_dataframe()
        file_read = TdmsFile.read(path)
        data = file_read.groups()[0].channels()[0].data
        
        plt.suptitle('Timeseries data', fontsize='30')
        plt.xlabel('Timestamp', fontsize ='20')
        plt.ylabel('feature values', fontsize='20')
        plt.plot(df.iloc[:,0])
        plt.show()
```</div>