Code Monkey home page Code Monkey logo

ndbfreader's People

Contributors

dsherret avatar exavera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ndbfreader's Issues

读取字符串乱码bug

StringColumn.cs文件中36行处方法DoLoad,修改个bug。之前一直解析乱码,修改后就好了。如下:

    protected override string DoLoad(byte[] buffer, int offset, Encoding encoding)
    {
        if (_parsedCharsBuffer == null)
        {
            _parsedCharsBuffer = new char[Size];
        }
        var bytes = buffer.Skip(offset).Take(Size).ToArray();
        
        var result = encoding.GetString(bytes).Trim('\0').Trim(' ');
        return result;
    }

image

HeaderLoader doesn't read, expose or use decimal count header field

Example:
image

This field will be parsed as Decimal (because it is N, not I), while the other readers recognize it as Integer field (10 digits, zero decimals as seen from the screenshot above)

  1. IColumn should have Decimals property, regardless of type - Int32 or Double
  2. HeaderLoader should populate this property

Some buffer offset problems when reading dbf rows

Hello.
I've spotted a problem, while reading data from columns.
fields
There I have a dbf.
You can see that "GDE" field has length of 5 and for the first record it contains " 1" (e.g. four spaces and "1"). when I'm using reader.GetValue or GetDecimal, it returns 0 to me. For the value " 11" it returns 1.
So I've started to suspect that it cuts the last byte and tried with another field.
I've tried to read from "REK1" field (yeap, its data looks clumsy), and it returned to me that value but with extra "1" before, so it looks that there's a problem with offset.

ADDED!

I've found the reason. That's the damn dBase 7 Extra properties (http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm). As I understood, they are optional, but the file of that format contains extra zero byte, if it doesn't contain that properties.
1
There we have terminating byte (red), dBase7 extra properties section (yellow, and it is empty, but the byte is present), then deletion marker (space or asterisk, green), and finally the value of first field (" 1", blue).

Please notice, that according to http://www.dbf2002.com/dbf-file-format.html, the 8th and 9th bytes contain offset of data, so we can just seek to that place, ignoring the extra properties.
2
data starts at 0x0422 = 1058 bytes, while currently NDbfReader will start from 1057

ADDED
I've changed a bit Load method in HeaderLoader:
....
BasicProperties properties = ParseBasicProperties(buffer);

var retVal = LoadColumns(stream, properties, buffer.Last());

var dataOffset = (buffer[DATA_START_OFFSET_H] << 8) | buffer[DATA_START_OFFSET_L];
stream.Seek(dataOffset, SeekOrigin.Begin);

return retVal;
....
DATA_START_OFFSET_H = 8;
DATA_START_OFFSET_L = 9;

p.s.
I'm new to github, I also want to fork this projects. I've added GetBytes method (in addition to GetValue), so now I can get raw bytes for any field I want (I'm just had a problem with decoding of crypted string in a string-typed field, so I did need a raw data to make some operations, without any encoding issues)..

Reader ignores actual column size

  • DateTime and FoxProDateTime columns expects size 8
  • BooleanColumn expects size 1

Some DBF files has the listed columns with bigger size filled by whitespace. NDbfReader can't load these files.

.GetValue() cares about column data type

I am trying to read bad data from a DateTime column. Because it cannot parse it to a DateTime it breaks, and I cannot find a suitable alternative method to collect this bad data so I would prefer to use .GetString(myCol) for all columns so I can deal with the parsing and error handling myself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.