2021-06-22 13:32:51 +00:00
|
|
|
import pandas as pd
|
2021-06-22 18:31:16 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
class CSV_handler:
|
|
|
|
|
2021-06-22 18:54:42 +00:00
|
|
|
def __init__(self):
|
2021-06-22 18:31:16 +00:00
|
|
|
self.working_dir = str(Path.cwd())
|
|
|
|
|
2021-06-22 19:00:51 +00:00
|
|
|
# Makes dataframe from the csv files in the working directory
|
2021-06-22 19:30:55 +00:00
|
|
|
def make_df(self, filename):
|
2021-06-22 18:31:16 +00:00
|
|
|
filepath = self.working_dir + str(filename)
|
|
|
|
df = pd.read_csv(filepath)
|
|
|
|
return df
|
2021-06-22 19:00:51 +00:00
|
|
|
|
|
|
|
# Extracts out the timestamp and the selected emg signal into a new dataframe
|
2021-06-22 18:54:42 +00:00
|
|
|
def get_time_emg_table(self, filename, emg_nr):
|
2021-06-22 18:31:16 +00:00
|
|
|
|
2021-06-23 08:32:38 +00:00
|
|
|
tot_data_frame = self.make_df(filename)
|
2021-06-22 18:54:42 +00:00
|
|
|
emg_str = "emg" + str(emg_nr)
|
2021-06-22 19:00:51 +00:00
|
|
|
filtered_df = tot_data_frame[["timestamp", emg_str]]
|
2021-06-22 18:54:42 +00:00
|
|
|
return filtered_df
|
2021-06-22 18:31:16 +00:00
|
|
|
|
2021-06-22 19:00:51 +00:00
|
|
|
|
2021-06-23 08:32:38 +00:00
|
|
|
handler = CSV_handler()
|
2021-06-22 19:00:51 +00:00
|
|
|
|
2021-06-23 08:32:38 +00:00
|
|
|
file = "/Exp20201205_2myo_hardTypePP/HaluskaMarek_20201207_1810/myoLeftEmg.csv"
|
|
|
|
subject1_left_emg1 = handler.get_time_emg_table(file, 1)
|
|
|
|
print(subject1_left_emg1.head)
|
|
|
|
#df = handler.make_df(file)
|
|
|
|
#print(df.head)
|
2021-06-22 18:31:16 +00:00
|
|
|
|
2021-06-22 13:32:51 +00:00
|
|
|
|
|
|
|
|