Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion about func "read_and_parse_txt_from_disk" #6

Open
GengYuIsland opened this issue May 10, 2024 · 0 comments
Open

Suggestion about func "read_and_parse_txt_from_disk" #6

GengYuIsland opened this issue May 10, 2024 · 0 comments

Comments

@GengYuIsland
Copy link

Moreover, I suggest this func should be changed like this, because I meet the encoding problem:

def read_and_parse_txt_from_disk(path_to_file,data_items):
    try:
        with open(path_to_file,'r',encoding='utf-8') as f:
            txt = f.read()
    except:
        with open(path_to_file,'r',encoding='latin1') as f:
            txt = f.read()
    txt = txt.split('\n')
    raw_patent_data= get_patents_list(txt)
    parsed_data = []
    for patent in raw_patent_data:
        parsed_data.append(parse_txt_patent_data(patent,data_items_list = data_items))
    return parsed_data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant