{"id":22356335,"url":"https://github.com/do-/dbf-reuse","last_synced_at":"2025-03-26T13:14:56.940Z","repository":{"id":66721611,"uuid":"422857170","full_name":"do-/dbf-reuse","owner":"do-","description":"Using old .dbf files as templates for new ones","archived":false,"fork":false,"pushed_at":"2022-04-11T12:59:34.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T10:40:47.408Z","etag":null,"topics":["dbf","streams"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/do-.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-30T11:04:39.000Z","updated_at":"2021-11-04T07:56:09.000Z","dependencies_parsed_at":"2023-04-06T00:23:55.737Z","dependency_job_id":null,"html_url":"https://github.com/do-/dbf-reuse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fdbf-reuse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fdbf-reuse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fdbf-reuse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-%2Fdbf-reuse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/do-","download_url":"https://codeload.github.com/do-/dbf-reuse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245659052,"owners_count":20651525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbf","streams"],"created_at":"2024-12-04T14:09:55.953Z","updated_at":"2025-03-26T13:14:56.934Z","avatar_url":"https://github.com/do-.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dbf-reuse\nUsing old .dbf files as templates for new ones\n\n# Motivation\nStarting this project, the author was developing a node.js based application and needed a library to implement data import/export with a legacy dBASE III+ format. Mostly for generating .dbf files looking just like old ones, but filled with actual data.\n\nHe scanned through the npm registry and have found some modules coping with .dbf (the most advanced of them being [dbffile](https://github.com/yortus/DBFFile)), but:\n* they all required access to file system;\n* none of then provided a streaming API.\n\nSo he decided to first create from scratch a minimalistic library:\n* doing nothing but converting javaScript objects to .dbf records and vice versa\n  * as Transformer streams, for easy piping\n* using existing .dbf files as source for metadata.\n\n# Installation\n\n```shell\nnpm install dbf-reuse\n```\n\n# Usage\n\nHere are some basic examples. More documentation is available at https://github.com/do-/dbf-reuse/wiki.\n\n## Reading\n\n```js\nconst {DBFReader} = require ('dbf-reuse')\n\nlet reader = new DBFReader ({\n//  encoding            : 'some-antique-dos-encoding'\n//  decoder             : b =\u003e b,       // why not reading C as raw Buffers?\n//  deletedFieldName    : '_deleted',   // if you need deleted records\n//  lowerCaseFieldNames : false         // 0LD $CHOOL\n})\n\nlet src = // ... .dbf file body as binary Readable Stream\nlet dst = // ... object mode Writable Stream to store parsed content\n\nsrc.pipe (reader).pipe (dst)\n\n```\n\n## Writing\n\nMaking an empty template (zero records .dbf) from an existing file:\n```js\nconst fs = require ('fs')\nconst {DBFWriter} = require ('dbf-reuse')\n\nlet is = fs.createReadStream ('big_old_data.dbf')\nlet os = fs.createWriteStream ('empty_template.dbf')\n\nawait DBFWriter.copyHeader (is, os)\n```\nFilling it up with data:\n```js\nconst fs          = require ('fs')\nconst zlib        = require ('zlib')\nconst {DBFWriter} = require ('dbf-reuse')\n\nlet template = fs.createReadStream ('empty_template.dbf')\n\nlet source = getRecordsAsReadableObjectStream ()\nlet count  = getRecordCountAsInt ()\n\nlet writer = await DBFWriter.from (tmpl, {\n//  encoding            : 'some-antique-dos-encoding',\n    count,                             // if not set, remains as copied from the template\n//  date                : new Date (), // if not set, remains as copied from the template\n//  encoder             : b =\u003e b,      // if you supply properly encoded Buffers, not strings, for `C`\n//  lowerCaseFieldNames : false        // 0LD $CHOOL\n})\n\nsomehowReportNewFileMetadata ({\n  name: 'DATA.DBF',\n  size: writer.getFileSize (),         // calculates UNcompressed size\n  //... MIME type and so on\n})\n\nlet destination = getWritableStreamToStoreIt () \n\nsource\n  .pipe (writer)\n  .pipe (zlib.createGzip ())           // think Content-Encoding: gzip\n  .pipe (destination)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-%2Fdbf-reuse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdo-%2Fdbf-reuse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-%2Fdbf-reuse/lists"}