Click here to Skip to main content
15,797,984 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:

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,
                print("its in!")
Updated 22-Dec-20 11:16am

1 solution

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

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:
                        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