Giter Club home page Giter Club logo

Comments (7)

landawn avatar landawn commented on August 28, 2024

It's a bug. The root cause is the JSONParserImpl class isn't initialized successfully due to the cycling dependence between it and class N. It's fixed in version 1.0.5. please download the new version and let me know if you have further questions.

Thank you for reporting the issue and I hope you will enjoy using the library.

from abacusutil.

kreecha avatar kreecha commented on August 28, 2024

Hi there
Thank you for the respond and fix, but found the new error is thrown as below. At least it is not the same so i can see i will be able to use your software soon :-)

Oct 29, 2017 12:15:06 PM com.landawn.abacus.logging.JDKLogger log
INFO: Initialized with JDK Logger
Exception in thread "main" java.lang.ArrayStoreException: java.util.ArrayList
at com.landawn.abacus.parser.JSONParserImpl.readArray(Unknown Source)
at com.landawn.abacus.parser.JSONParserImpl.readString(Unknown Source)
at com.landawn.abacus.parser.JSONParserImpl.readString(Unknown Source)
at com.landawn.abacus.parser.AbstractJSONParser.readString(Unknown Source)
at com.landawn.abacus.util.CSVUtil.loadCSV(CSVUtil.java:195)
at com.landawn.abacus.util.CSVUtil.loadCSV(CSVUtil.java:134)
at com.landawn.abacus.util.CSVUtil.loadCSV(CSVUtil.java:100)
at com.landawn.abacus.util.CSVUtil.loadCSV(CSVUtil.java:80)
at com.landawn.abacus.util.CSVUtil.loadCSV(CSVUtil.java:76)
at com.landawn.abacus.util.CSVUtil.loadCSV(CSVUtil.java:72)
at util.ActIDActNameSrcIpTime.TestAbacus.main(TestAbacus.java:20)

from abacusutil.

landawn avatar landawn commented on August 28, 2024

Could you please show me your test code and couple of lines of the sample CSV file? so i can find out the root cause?

from abacusutil.

kreecha avatar kreecha commented on August 28, 2024

from abacusutil.

landawn avatar landawn commented on August 28, 2024

Thanks! i didn't find the attached CSV file you used for test for some reason. Can you please check it for me or upload it again if it's missed?

from abacusutil.

kreecha avatar kreecha commented on August 28, 2024

from abacusutil.

landawn avatar landawn commented on August 28, 2024

I still didn't see the attached CSV file you used for test. but anyway, if you want to continue to give it a try. Here are my suggestions:
If the column values in the CSV files are quoted with " or ' except type: number or boolean. For example 001.csv:

first_name, last_name, number
"tom", "cruise", 1
"tom", "hanks", 2

The simplest way to load it to DataSet is:

File csv001 = new File("./001.csv");
DataSet ds001 = CSVUtil.loadCSV(csv001);
ds001.println();

If the column values in the CSV file are not quoted with with " or ' for some reason. For example:

first_name, last_name, number
tom, cruise, 1
tom, hanks, 2

You can try Apache Commons CSV

try (CSVParser csvParser = CSVParser.parse(csv001, Charsets.UTF_8, CSVFormat.DEFAULT)) {
    DataSet ds002 = Stream.of(csvParser.iterator()).map(e -> Iterators.toList(e.iterator()))
            .headAndTail().map((h, t) -> t.toDataSet(h.get()));
    ds002.println();
}

Or you can also manually parse the CSV file(This could be the fastest way):

String delimiter = ", "; // which could be ',', Tab spaces or any string used to delimit the values in the CSV.
DataSet ds003 = Stream.of(csv001)
        .call(s -> s.map(e -> N.splitPreserveAllTokens(e, delimiter))
                .headAndTail().map((h, t) -> t.toDataSet(Arrays.asList(h.get()))));
ds003.println();

// or:
try (LineIterator iter = IOUtil.iterate(csv001)) {
    ds003 = Stream.of(iter)
            .map(e -> N.splitPreserveAllTokens(e, delimiter))
            .headAndTail().map((h, t) -> t.toDataSet(Arrays.asList(h.get())));
}

from abacusutil.

Related Issues (20)

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.