daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest May 16th, 2018 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2.  
  3. filePath = '/Users/u/filewithspecialcharacters.csv'
  4. fileEncoding = 'iso-8859-1'
  5.  
  6. pattern = r"^[a-zA-Z0-9_;:!@?'.#(){}*|~/+%&<>,–`=\"\s\-\$\[\]\^\\]*$"
  7. compiledPattern = re.compile(pattern)
  8.  
  9. count = 0
  10.  
  11. with open(filePath,'r',encoding=fileEncoding) as file:
  12.     for line in file:
  13.         if not re.match(compiledPattern, line):
  14.             count = count + 1
  15.             print(line)
  16.  
  17. print('No of lines with special characters: ',count)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top