Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import sys
  2.  
  3. def zeros_count(list):
  4.     zeros = 0
  5.     for l in list:
  6.         if float(l) == 0:
  7.             zeros += 1
  8.     print(zeros)
  9.     return zeros
  10.  
  11. def main():
  12.     inp, out = sys.argv[1], sys.argv[2]
  13.  
  14.     with open(inp, "r") as input:
  15.         with open(out, "w") as output:
  16.             i = 0
  17.             for line in input:
  18.                 if i == 0:
  19.                     i += 1
  20.                     continue
  21.                 z = line.split()
  22.                 sen, date, *hist = z
  23.                 if zeros_count(hist) / len(hist) < 0.3:
  24.                     output.write(line)
  25.             output.close()
  26.         input.close()
  27.  
  28. if __name__ == '__main__':
  29.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement