-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfreq-2.py
More file actions
66 lines (48 loc) · 1.41 KB
/
freq-2.py
File metadata and controls
66 lines (48 loc) · 1.41 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
# read data from file
import csv
#import numpy as np
import matplotlib.pyplot as plt
from collections import Counter
def writeToFile(row6,row7,row8):
thefile = open('data.txt', 'w')
for i in range(0,len(row6)):
thefile.write("%s %s %s\n" % (row6[i],row7[i],row8[i]))
#print (item6,item7,item8
#rowValue = input("Enter the row value")
rowValue = [5,6,7,8]
row6=[]
row7=[]
row8=[]
result = []
i=0
data_file = "try" #replace with your file name
with open(data_file,'rU') as f:
reader = csv.reader(f, delimiter=' ')
for row in reader:
print(i)
i = i+1
fine = float(row[rowValue[1]])/float(row[rowValue[0]])
#fine = fine
row6.append(fine)
#for row 7
fine = float(row[rowValue[2]])/float(row[rowValue[0]])
#fine = float(fine)
row7.append(fine)
#for row 8
fine = float(row[rowValue[3]])/float(row[rowValue[0]])
#fine = float(fine)
row8.append(fine)
print(row8[0])
sorted_data = sorted(row8)
count = Counter(sorted_data)
#call function to write to file
writeToFile(row6,row7,row8) # you can change name of the file if u want
n = len(sorted_data)
plt.hist(sorted_data,bins=500,histtype='step')
#plt.axis([0,1.1,0,400])
plt.title("Arabian Sea ") #e11nter ur title here
plt.xlabel("fine fraction ")
plt.ylabel("Frequency")
plt.show()
print "done"
#count of occurance of list items