-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_processing.py
121 lines (109 loc) · 2.1 KB
/
file_processing.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import os
import numpy as np
def showData(data, names):
i = 0
while i < data.shape[0]:
print(names[i] + ": ")
j = 0
while j < data.shape[1]:
print(data[i][j])
j += 1
print("")
i += 1
def Main():
print("The sample data is: ")
fname = 'data.csv'
csv = np.genfromtxt(fname, dtype=str, delimiter=",")
num_rows = csv.shape[0] # x axis in graphics computer
num_cols = csv.shape[1] # y axis in graphics computer
names = csv[1:,0]
# get data frame from the first column to the end colums
data = np.genfromtxt(fname, usecols = range(1,num_cols), delimiter=",")
print(names)
print(str(num_rows) + "x" + str(num_cols))
print(data)
showData(data, names)
#The sample data is:
#['CONFIG000' 'CONFIG001' 'CONFIG010' 'CONFIG011' 'CONFIG100' 'CONFIG101'
# 'CONFIG110' 'CONFIG111']
#8x9
#[[ 1080.65 1080.87 1068.76 1083.52 1084.96 1080.31 1081.75 1079.98]
# [ 414.6 421.76 418.93 415.53 415.23 416.12 420.54 415.42]
# [ 1091.43 1079.2 1086.61 1086.58 1091.14 1080.58 1076.64 1083.67]
# [ 391.31 392.96 391.24 392.21 391.94 392.18 391.96 391.66]
# [ 1067.08 1062.1 1061.02 1068.24 1066.74 1052.38 1062.31 1064.28]
# [ 371.63 378.36 370.36 371.74 370.67 376.24 378.15 371.56]
# [ 1060.88 1072.13 1076.01 1069.52 1069.04 1068.72 1064.79 1066.66]
# [ 350.08 350.69 352.1 350.19 352.28 353.46 351.83 350.94]]
#CONFIG000:
#1080.65
#1080.87
#1068.76
#1083.52
#1084.96
#1080.31
#1081.75
#1079.98
#CONFIG001:
#414.6
#421.76
#418.93
#415.53
#415.23
#416.12
#420.54
#415.42
#CONFIG010:
#1091.43
#1079.2
#1086.61
#1086.58
#1091.14
#1080.58
#1076.64
#1083.67
#CONFIG011:
#391.31
#392.96
#391.24
#392.21
#391.94
#392.18
#391.96
#391.66
#CONFIG100:
#1067.08
#1062.1
#1061.02
#1068.24
#1066.74
#1052.38
#1062.31
#1064.28
#CONFIG101:
#371.63
#378.36
#370.36
#371.74
#370.67
#376.24
#378.15
#371.56
#CONFIG110:
#1060.88
#1072.13
#1076.01
#1069.52
#1069.04
#1068.72
#1064.79
#1066.66
#CONFIG111:
#350.08
#350.69
#352.1
#350.19
#352.28
#353.46
#351.83
#350.94