Closed karandeep8 closed 1 year ago
@karandeep8 would be great to share what the issue was so that other people in the future could resolve similar problems. I would assume that the issue was mostly related to paths, but please give a detailed description. Thanks :)
Sir, after this script a_convert_to_csv.py, an empty folder is created, the respective folder does not contain any csv file, can you please help me, how to do the conversion properly?
Code that I am using
from pathlib import Path
import numpy as np import pandas as pd import wfdb # WaveForm-Database package. A library of tools for reading, writing, and processing WFDB signals and annotations.
def convert_to_csv(path='stress-recognition-in-automobile-drivers-1.0.0./', new_folder=True): """ Code to convert all .dat files (ECG signals) in a folder to CSV format Path - location of the dat files (str) new_folder - whether to put the files in a new csv folder (boolean)
def read_data(path, extension=".csv"): """ Function to read the all the csv/dat files. Since there are many files, it returns an iterator. path - path to the csv/dat files. extension - csv/dat. (if csv, it returns the dataframe else only filename) """ file_paths = Path(path).glob(extension) for file in file_paths: if extension == ".csv": dataset = pd.read_csv(file) yield file.stem, dataset else: yield file
convert_to_csv()
It would be a great help.