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

no memo #65

Closed anazar closed 9 years ago

anazar commented 9 years ago

Is it possible to properly read a file without having the corresponding memo file? I have the same issue outlined in #64 since I don't have the memo file.

infused commented 9 years ago

It is possible to read the file even with a missing memo file. Any memo fields will be returned as nil without the memo file, but everything else should work ok.

It could be a an issue with a specific type of dbf file. What is the output from dbf -s <your dbf filename> ?

anazar commented 9 years ago

Here is the output

Database: test/files/dbase/2/0375413v.veh
Type: (8b) dBase IV with memo file
Memo File: false
Records: 1

Fields:
Name             Type       Length     Decimal
------------------------------------------------------------------------------
IMPACT_1         C          2          0         
IMPACT_2         C          30         0         
DMG_MEMO         M          10         0         
DB_V_CODE        C          7          0         
PLATE_NO         C          10         0         
PLATE_ST         C          2          0         
V_VIN            C          25         0         
V_COND           C          2          0         
V_PROD_DT        C          4          0         
V_MODEL_YR       C          2          0         
V_MAKECODE       C          12         0         
V_MAKEDESC       C          20         0         
V_MODEL          C          50         0         
V_TYPE           C          2          0         
V_BSTYLE         C          20         0         
V_TRIMCODE       C          20         0         
TRIM_COLOR       C          20         0         
V_MLDGCODE       C          20         0         
V_ENGINE         C          20         0         
V_MILEAGE        C          6          0         
V_OPTIONS        M          10         0         
V_COLOR          C          20         0         
V_TONE           N          1          0         
V_STAGE          N          1          0         
PAINT_CD1        C          15         0         
PAINT_CD2        C          15         0         
PAINT_CD3        C          15         0         
V_MEMO           M          10         0         

The problem also outlined in #64 causes this issue: without memo file:

table.first.attributes
=> {"IMPACT_1"=>"03",
 "IMPACT_2"=>"",
 "DMG_MEMO"=>nil,
 "DB_V_CODE"=>"",
 "PLATE_NO"=>"918751",
 "PLATE_ST"=>"7E",
 "V_VIN"=>"AV728   CA4T3ZF13C1WU0308",
 "V_COND"=>"56",
 "V_PROD_DT"=>"",
 "V_MODEL_YR"=>"",
 "V_MAKECODE"=>"FR    9845",
 "V_MAKEDESC"=>"Toyota",
 "V_MODEL"=>"Sienna",
 "V_TYPE"=>"",
 "V_BSTYLE"=>"TKVan 114\" W",
 "V_TRIMCODE"=>"B",
 "TRIM_COLOR"=>"",
 "V_MLDGCODE"=>"",
 "V_ENGINE"=>"",
 "V_MILEAGE"=>"",
 "V_OPTIONS"=>nil,
 "V_COLOR"=>"238037         1",
 "V_TONE"=>0,
 "V_STAGE"=>0,
 "PAINT_CD1"=>"N",
 "PAINT_CD2"=>"00",
 "PAINT_CD3"=>"",
 "V_MEMO"=>nil}

With memo file:

table.first.attributes
=> {"IMPACT_1"=>"03",
 "IMPACT_2"=>"",
 "DMG_MEMO"=>nil,
 "DB_V_CODE"=>"918751",
 "PLATE_NO"=>"7EAV728",
 "PLATE_ST"=>"CA",
 "V_VIN"=>"4T3ZF13C1WU030856",
 "V_COND"=>"FR",
 "V_PROD_DT"=>"",
 "V_MODEL_YR"=>"98",
 "V_MAKECODE"=>"45",
 "V_MAKEDESC"=>"Toyota",
 "V_MODEL"=>"Sienna",
 "V_TYPE"=>"TK",
 "V_BSTYLE"=>"Van 114\" WB",
 "V_TRIMCODE"=>"",
 "TRIM_COLOR"=>"",
 "V_MLDGCODE"=>"",
 "V_ENGINE"=>"",
 "V_MILEAGE"=>"238037",
 "V_OPTIONS"=>">\x03\x00\x00000001;Passenger Airbag\r\n",
 "V_COLOR"=>"BRN",
 "V_TONE"=>0,
 "V_STAGE"=>0,
 "PAINT_CD1"=>"",
 "PAINT_CD2"=>"",
 "PAINT_CD3"=>"",
 "V_MEMO"=>nil}
anazar commented 9 years ago

Here is the file to download: https://www.dropbox.com/s/1u7e1vizpflrjz0/0375413v.veh

infused commented 9 years ago

Thanks for making a test file available. I was able to find and fix the problem. I've released version 2.0.9 that includes the fix. Please confirm that it solves the issue for you.

anazar commented 9 years ago

:+1: You are awesome! Thanks so much for the quick fix. Worked perfectly.