dbf-parser

raw JSON →
0.0.1 verified Sat May 09 auth: no javascript maintenance

An event-based, pure JavaScript parser for reading data from dBase (.dbf) files. Based on node-dbf but adds float type support, correct handling of numeric fields, and works without CoffeeScript. Version 0.0.1 is stable but minimal: only Character and Numeric field types are supported. Primarily for Node.js, uses EventEmitter for streaming output. Not actively maintained; alternative libraries like dbf or shapefile-js may offer more complete implementations.

error Error: Unsupported field type: D
cause Date field type (type code 'D') is not supported.
fix
Remove or convert Date fields to Character or Numeric before processing.
error TypeError: parser.on is not a function
cause Forgot to call new Parser() and use require correctly.
fix
Ensure you use 'const parser = new Parser(path);' after requiring the module.
error Cannot find module 'dbf-parser'
cause Module not installed or path is incorrect.
fix
Run 'npm install dbf-parser' in your project directory.
error RangeError: File size exceeds maximum buffer
cause Large file being read entirely into memory via fs.readFile.
fix
Use a streaming parser like 'dbf' (npm package) for files over 1GB.
gotcha Only Character and Numeric field types are supported; other types (e.g., Date, Logical) may cause parse errors or undefined behavior.
fix Pre-process .dbf file to ensure only supported types, or use a more full-featured library like dbf.
gotcha The module is not actively maintained; last updated years ago. Known issues with large files and unsupported field types.
fix Consider alternatives like shapefile-js or dbf for ongoing support and features.
gotcha Uses synchronous fs.readFile internally, so large .dbf files may block the event loop. Documentation mentions intended switch to fs.readStream but not implemented.
fix For large files, use a streaming parser like dbf (npm package) or chunk the file manually.
gotcha Record field values are trimmed of padding characters, which may remove legitimate leading/trailing spaces.
fix If field padding is significant, use a different parser that preserves raw content.
npm install dbf-parser
yarn add dbf-parser
pnpm add dbf-parser

Shows how to create a parser, register event handlers, and start parsing a .dbf file.

const Parser = require('dbf-parser');
const parser = new Parser('/path/to/file.dbf');

parser.on('start', () => console.log('Parsing started'));
parser.on('header', (header) => console.log(header));
parser.on('record', (record) => console.log(record));
parser.on('end', () => console.log('Parsing complete'));

parser.parse();