Skip to content

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

@adityabhandwalkar

Description

@adityabhandwalkar

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions