-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveNegative.py
More file actions
39 lines (28 loc) · 865 Bytes
/
removeNegative.py
File metadata and controls
39 lines (28 loc) · 865 Bytes
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
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 01 19:57:18 2016
Removes negative values and rounds values to 2
@author:
"""
import csv
#import numpy as np
data_file = "try.txt"
f2 = open('output1', 'w')
#rowValue = input("Enter the row value")
rowValue1 = 6
rowValue2 = 7
result = []
with open(data_file,'r') as f:
reader = csv.reader(f, delimiter=' ')
for row in reader:
if float(row[rowValue1]) >=0 and float(row[rowValue2]) >=0:
row = filter(None, row) #this i used to remove extra space
f2.write("\n")
for item in row:
if '-'not in item and ':' not in item:
item = str(round(float(item),2)) /
f2.write("%s " % item)
else:
f2.write("%s " % item)
f2.close()
print "done"