-
Notifications
You must be signed in to change notification settings - Fork 2
/
columnSorter.py
45 lines (35 loc) · 2.43 KB
/
columnSorter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 01 01:11:52 2015
@author: Shamir
"""
import pandas
import os
#gesture_path = 'C:\\Users\\Shamir\\Desktop\\Grad\\Gesture Stuff\\Data_Multisensor\\' # use input() to make it interactive
gesture_path = 'C:\\Users\\Shamir\\Desktop\\Hands_Sorted\\test\\'
#destination = 'C:\\Users\\Shamir\\Desktop\\broken down files\\'
destination = 'C:\\Users\\Shamir\\Desktop\\Hands_Sorted\\test\\'
fileformat = '.csv'
backslash = '\\'
count = 1
for i in range(len(os.listdir(gesture_path))): # we have 6 files corresponding to 6 gestures
gesture = os.listdir(gesture_path)[i] # Jab, Uppercut, Throw, Jets, Block, Asgard
for j in range(len(os.listdir(gesture_path + gesture))): # we have 3 files corresponding to 3 datasets (train, cross-validation, test)
dataset = os.listdir(gesture_path + gesture)[j] # Train, Cross Validation, Test
for k in range(len(os.listdir(gesture_path + gesture + backslash + dataset))): # we have 5 sensors (15,16,17,18,19)
file = os.listdir(gesture_path + gesture + backslash + dataset)[k] # desired csv file in the folder
csvfile = gesture_path + gesture + backslash + dataset + backslash + file # full filepath
print csvfile
readFile = pandas.read_csv(csvfile, header = None) # read csv file
qr = readFile.loc[:, range(0, readFile.shape[1], 5)] # qr columns only
qr.to_csv(destination + str(count) + fileformat, header = False, index = False)
count += 1
qx = readFile.loc[:, range(1, readFile.shape[1], 5)] # qx columns only
qx.to_csv(destination + str(count) + fileformat, header = False, index = False)
count += 1
qy = readFile.loc[:, range(2, readFile.shape[1], 5)] # qy columns only
qy.to_csv(destination + str(count) + fileformat, header = False, index = False)
count += 1
qz = readFile.loc[:, range(3, readFile.shape[1], 5)] # qz columns only
qz.to_csv(destination + str(count) + fileformat, header = False, index = False)
count += 1