# -*- coding:utf-8 -*-
"""
作者:sunli
日期:2022年06月21日14:49
"""
# -*- coding:utf-8 -*-
import os
import numpy as np
import pandas as pd
path0 = r"D:\shujuji\SisFall_dataset"
path1 = r"D:\shujuji\SisFall_dataset" + '\\'
# 列出當前目錄下所有的文件
files = os.listdir(path0)
print('files', files)
for filename in files:
path = path1 + filename
file = os.listdir(path)
for file_ in file:
portion = os.path.splitext(file_)
# 如果後綴是.csv
if portion[1] == ".csv":
filenamedir = path + '\\'+ file_
data = pd.read_csv(filenamedir, index_col=False, header=None)
data_size = len(data)
col_data = np.arange(0, data_size, 1)
extract_data = data.iloc[col_data, [0, 1, 2, 3, 4, 5]]
extract_data.columns = ["acc_x", "acc_y", "acc_z", "gyro_x", "gyro_y", "gyro_z"]
extract_data.to_csv(filenamedir, index=None)