Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. ZADANIE 2
  2.  
  3. #!/usr/bin/env python
  4. # -*- coding: utf-8 -*-
  5.  
  6. import sys
  7. import re
  8.  
  9. counter = 0
  10.  
  11. with open('B02.csv') as f:
  12. lineNumber = sum(1 for _ in f)
  13.  
  14. with open('B02.csv') as f:
  15. for line in f:
  16. line = line.rstrip('\n')
  17. regLine = re.search("^(.)+;(-)*(\d)+;(-)*(\d)+;", line)
  18. if (regLine):
  19. counter = counter + 1
  20.  
  21. if (lineNumber == counter):
  22. print "Csv file is valid"
  23. else:
  24. print "Csv file is not valid"
  25. -----------------------------------------------------------------------------------------------
  26.  
  27. ZADANIE 4
  28.  
  29. #!/usr/bin/env python
  30. # -*- coding: utf-8 -*-
  31.  
  32. import sys
  33. import re
  34.  
  35. file = open(sys.argv[1], 'r')
  36. try:
  37. content = file.read();
  38. match = re.findall(r'[\w\.-]+@[\w\.-]+', content)
  39. finally:
  40. file.close();
  41.  
  42. print match
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement