#!/usr/bin/python
data = open("/home/mia/Desktop/results/all-nodup.txt", "r")
fd = open("/home/mia/Desktop/results/all-filter.txt", "w")
last_time = 0.0
last_ip = None
last_hash = None
row = data.read()
for line in row:
timestamp, ip, hash_value = line.split()
if ip==last_ip and hash_value==last_hash:
if float(timestamp) - float(last_time) >= 5.0:
fd.write("%s\t%s\t%s\n" % (str(timestamp), str(ip), str(hash_value)))
last_time, last_ip, last_hash = timestamp, ip, hash_value
else:
fd.write("%s\t%s\t%s\n" % (str(timestamp), str(ip), str(hash_value)))
last_time, last_ip, last_hash = timestamp, ip, hash_value
fd.close()
This is my entire code, I go to results/ directory to run: python filter.py
I got an error message: python: can't open file 'filter.py': [Errno 2] No such file or directory
But every other scripts can be executed, so python works fine, maybe I should import something in this case?
ls filter.pyshow? How abouthead -1 filter.py?