EMG_Biometrics_2021/Handle_emg_data.py
2021-06-23 10:40:55 +02:00

29 lines
727 B
Python

import pandas as pd
from pathlib import Path
class CSV_handler:
def __init__(self):
self.working_dir = str(Path.cwd())
# Makes dataframe from the csv files in the working directory
def make_df(self, filename):
filepath = self.working_dir + str(filename)
df = pd.read_csv(filepath)
return df
# Extracts out the timestamp and the selected emg signal into a new dataframe
def get_time_emg_table(self, filename, emg_nr):
tot_data_frame = self.make_df(filename)
emg_str = self.get_emg_str(emg_nr)
filtered_df = tot_data_frame[["timestamp", emg_str]]
return filtered_df
def get_emg_str(emg_nr):
return 'emg' + str(emg_nr)