albfernandez / javadbf

Java library for reading and writing Xbase (dBase/DBF) files.
GNU Lesser General Public License v3.0
220 stars 98 forks source link

While reading the nextRecord i am getting 'E' values #102

Closed medari1048 closed 8 months ago

medari1048 commented 2 years ago

I'm parsing a file and I get this error when I call reader.nextRecord()

while ((rowObjects = reader.nextRecord()) != null) { for (int i = 0; i < rowObjects.length; i++) {
Double dataNumber = (Double.parseDouble((String.valueOf(rowObjects[0]).trim()))); System.out.println(new BigDecimal(dataNumber).toPlainString());
} }

i am getting e values and that to wrong values i am getting

DBF Files : https://github.com/chinna1048/dbf_files

albfernandez commented 2 years ago

I'm not sure of the reading of DOUBLE values. What software are you using to generate this files? What should be the first value?

medari1048 commented 2 years ago

added a commit that referenced this issue 6 hours ago

Hi sir,

i reading this in eclipse with java 1.8 and dbf-reader version is 1.13.2

Gradle : implementation group: 'com.github.albfernandez', name: 'javadbf', version: '1.13.2'

import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import com.linuxense.javadbf.DBFField; import com.linuxense.javadbf.DBFReader;

public class Test { public static void main(String[] args) {

    String path = "C:\\Users\\User\\Desktop\\age.dbf";
    try {

        InputStream inputStream = new FileInputStream(path);

        DBFReader reader = new DBFReader(inputStream);

// reader.setMemoFile(new File(path));

        int numberOfFields = reader.getFieldCount();
        List<Object> headers = new ArrayList<Object>();
        for (int i = 0; i < numberOfFields; i++) {
            DBFField field = reader.getField(i);
            headers.add(field.getName());
        }

        Object[] rowObjects;

        while ((rowObjects = reader.nextRecord()) != null) {
            for (int i = 0; i < rowObjects.length; i++) {
                  System.out.println(rowObjects[i]);
            }
             System.out.println(headers.get(0) + "==" + rowObjects[0]);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

}

medari1048 commented 2 years ago

I'm not sure of the reading of DOUBLE values. What software are you using to generate this files? What should be the first value?

I observed issues where i am getting its coming for dBase IV versions, for dbase III version its working fine.

i thing we need to change the jar version instead of 1.13.2

implementation group: 'com.github.albfernandez', name: 'javadbf', version: '1.13.2'