Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What i have tried gave me the following error: line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc9 in position 99: invalid continuation byte

What I have tried:

Python
import os
import re


pattern = r'/d/d/d-/d/d/d-/d/d/d/d'

for folder, sub_folders,files in os.walk("/Users/alain/Downloads/extracted_content"):
    for file in files:
        with open(os.path.join(folder,file),'r') as f:
            if re.findall(pattern,f.read()):
                print("its in!")
Posted
Updated 22-Dec-20 10:16am
v3

1 solution

for the people with similar issues, i fixt it with the following adjustments

Python
import os
import re


pattern = r'\d{3}-\d{3}-\d{4}'

for folder, sub_folder, files in os.walk(r'/Users/alain/Downloads/extracted_content'):
    for file in files:
        if file.endswith('txt'):
            with open(os.path.join(folder, file)) as stream:
                for line in stream:
                    if re.search(pattern,line):
                        print("its in!")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900