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

how to use? #7

Open
RohitNegi12 opened this issue Nov 13, 2023 · 1 comment
Open

how to use? #7

RohitNegi12 opened this issue Nov 13, 2023 · 1 comment

Comments

@RohitNegi12
Copy link

The lzma_decompress script decompresses the data into a different format which has .p extension and how to convert this .p into a standard form like csv ?

@gokdumano
Copy link

gokdumano commented Feb 23, 2024

You can you this function to turn *.lzma files into records (dictionaries), then save them in any format you would like @RohitNegi12

from collections import defaultdict
from typing import Iterator

import compress_pickle

def lzma2records(fpath:str) -> Iterator[dict]:
    dd = defaultdict(list) 
    for values, fields in compress_pickle.load(fpath, compression='lzma'):
        for value, key in zip(values.split(), fields): dd[key].append(value)
        record = {key: ' '.join(value) for key, value in dd.items()}
        
        record['FullText'] = values

        yield record
        dd.clear()

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

2 participants