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

read huge data #62

Closed
wants to merge 3 commits into from
Closed

read huge data #62

wants to merge 3 commits into from

Conversation

fabiooshiro
Copy link

@fabiooshiro fabiooshiro commented Jan 16, 2022

When I tried to read the 1,28 GB file from
http://svs.aids.gov.br/dantps/centrais-de-conteudos/dados-abertos/sim/
http://svs.aids.gov.br/dantps/centrais-de-conteudos/dados-abertos/sim/DO21OPEN.zip

my computer cant open that file, so I did a change to allow an optional handler to read the data without keep all records in memory.

Example:
https://github.com/fabiooshiro/covid

@yortus
Copy link
Owner

yortus commented Jan 19, 2022

Hi @fabiooshiro, thanks for the PR! The current API is already designed to read very large files by reading records in batches. I've outlined an example below that should hopefully work fine for your case. As such I don't think the changes in this PR are necessary, so I'll be closing this. If you have any problems please feel free to post back here or create a new issue.

const BATCH_SIZE = 1000;
(async () => {
    const dbf = await DBFFile.open('./DO21OPEN.dbf');
    while (true) {
        // read the next batch of records
        const records = await dbf.readRecords(BATCH_SIZE);

        // exit the while loop when no more records are read
        if (records.length === 0) break; // done

        // process each record in this batch
        for (const record of records) {
            // process each record here...
        }
    }
})();

@yortus yortus closed this Jan 19, 2022
@fabiooshiro
Copy link
Author

Now I understand.
Thank you!

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

Successfully merging this pull request may close these issues.

None yet

2 participants