infused / dbf

DBF is a small, fast Ruby library for reading dBase, xBase, Clipper, and FoxPro database files.
http://rdoc.info/projects/infused/dbf
MIT License
262 stars 88 forks source link

dBASE II (version 0x02) support #92

Closed SheetJSDev closed 3 years ago

SheetJSDev commented 3 years ago
Traceback (most recent call last):
    13: from /usr/local/bin/dbf:23:in `<main>'
    12: from /usr/local/bin/dbf:23:in `load'
    11: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/bin/dbf:55:in `<top (required)>'
    10: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:199:in `to_csv'
     9: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:101:in `column_names'
     8: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:108:in `columns'
     7: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:213:in `build_columns'
     6: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:291:in `safe_seek'
     5: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:215:in `block in build_columns'
     4: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:215:in `tap'
     3: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:218:in `block (2 levels) in build_columns'
     2: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/table.rb:218:in `new'
     1: from /Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/column.rb:45:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/dbf-4.1.3/lib/dbf/column.rb:115:in `validate_name': column name cannot be empty (DBF::Column::NameError)

dBASE II .dbf files (version byte is 0x02) always have 32 header entries and the first row starts at byte offset 0x0209. Unfortunately it has to be special-cased as it differs from dBASE III and future dBASE/FoxBASE/FoxPro/VFP files in other ways.

Sample file -- GH does not support .dbf file extension, so just remove the ".xls" from the file and test it out.

infused commented 3 years ago

I've tried to open this file with a few other dbase utilities, but they all crash or error out when trying to open this file. When I look at the field descriptors, the 1st field name seems to be corrupt (or I'm using the wrong character encoding) because it contains a bunch of control characters. Do you know what character encoding this file uses and have you successfully opened it with any other utilities?

infused commented 3 years ago

Added support for "02" type files in version 4.1.4