-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuni-1.py
More file actions
161 lines (144 loc) · 4.17 KB
/
Copy pathuni-1.py
File metadata and controls
161 lines (144 loc) · 4.17 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Some data manipulation techniques without numpy and pandas!! ---> Important concepts.
import sys
#import matplotlib.pyplot as plt
# Reading Data from a CSV file ---------- Without Pandas & Numpy
delimit = ','
infile = open('C:/Users/ankes/Desktop/data_stored.csv', 'r')
import csv
newdata = []
rows = 0
for row in csv.reader(infile,delimiter=delimit):
rows += 1
if rows >= 0:
newdata.append(row)
rows = -1
# To find total list items in vector infile
infile.seek(0)
ncol = len(next(infile))
print("Total number of data items in list vector: ",ncol)
print(newdata[5][0])
# Counting Rows & Columns in CSV --------------------------- Without Pandas & Numpy
rows = 0
colcount = 0
for row in newdata:
rows += 1
if colcount < 1:
try:
data = newdata[0][rows]
except IndexError as error:
print("Last Column Reached!!")
cols = rows
colcount = 1
row_iterator = rows
col_iterator = cols
print("Last Row Reached!!")
print("No. of columns in CSV: ", cols)
print("No. of rows in CSV: ", rows)
#print(newdata)
# First covert str dataframe to int :
rows = 0
sort = []
for row in newdata:
if rows < row_iterator - 1 :
try:
rows += 1
#print(int ((newdata[rows][0])))
sort.append(int(newdata[rows][0]))
except ValueError:
break
rpeak_index = []
rpeak = []
identifier_matrix = []
rows = 0
cnt_c = 0
temp = 0
for row in sort:
if rows < row_iterator - 1 :
try:
rows += 1
if((((sort[rows]) > 391000))):
#print(sort[rows])
rpeak_index.append(rows)
rpeak.append(sort[rows])
var = rows - temp
identifier_matrix.insert(cnt_c,[sort[rows], rows, var])
cnt_c += 1
temp = rows
except ValueError:
break
except IndexError:
break
#print(rpeak_index)
#print(rpeak)
print("Identifier Matrix>>>\n",identifier_matrix)
sample_diff = []
rows = 0
for row in rpeak_index:
if rows < row_iterator - 1 :
try:
rows += 1
var = rpeak_index[rows] - rpeak_index[rows-1]
sample_diff.append(var)
except ValueError:
break
except IndexError:
break
#print(sample_diff)
sample_count = rows
reference = []
rows = 0
for row in sample_diff:
if rows <= sample_count :
try:
#print(int ((newdata[rows][0])))
reference.append(sample_diff[rows])
rows += 1
except ValueError:
break
except IndexError:
break
rows = 0
rows2 = 0
unique_value_count = []
cnt_c = 0
#print(sample_diff)
#print(reference)
repeat_count = 0
for row in reference:
if rows < 2*sample_count :
try:
if(reference[rows] == 0):
rows+=1
rows2 += 1
if(rows!=0):
rows2 = rows
var = reference[rows]
repeat_count = 1
#print(var)
for row in reference:
try:
if(var == 0):
break
rows2 += 1
#print(var, reference[rows2])
if(var == reference[rows2]):
reference[rows2] = 0
repeat_count += 1
except ValueError:
print("value_inner")
break
except IndexError:
#print(var, "-", repeat_count)
unique_value_count.insert(cnt_c,[var,repeat_count])
rows += 1
cnt_c += 1
#print("index_inner")
break
except ValueError:
print("value_outer")
break
except IndexError:
print("\nIterations Completed!\n")
break
#print(reference)
print("R Peak Periodicity in Samples>>>>>> ", unique_value_count)