haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
6k stars 1.12k forks source link

NoClassDefFoundError: org/apache/commons/csv/CSVFormat$Builder #782

Closed byTianHai closed 1 month ago

byTianHai commented 1 month ago

Describe the bug

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/csv/CSVFormat$Builder
    at smile.io.Read.csv(Read.java:136)
    at com.smile.LR.main(LR.java:21)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.csv.CSVFormat$Builder
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

Expected behavior

I want to Read into the csv file by read.csv ([String path, String format) and be able to recognize the column names

Actual behavior

This method cannot be run, and the default csv(String path) method does not recognize column names

Code snippet

        String format = "header=true";
        String csvFilePath = "coaldata.csv";
        DataFrame df = Read.csv(csvFilePath,format);
        System.out.println(df);

Input data coalProduction,drainage,industrialUsage,domesticUsage,waterTreatment,waterStorage,discharge 1000,200,150,80,60,70,90 1010,202,152,82,62,72,92 1020,205,155,85,64,74,94 1030,208,158,88,66,76,96 1040,210,160,90,68,78,98 1050,213,162,92,70,80,100 1060,215,165,94,72,82,102 1070,218,168,96,74,84,104 1080,220,170,98,76,86,106

Additional context

haifengl commented 1 month ago

To read csv, smile leverages Apache csv package. If you use smile through maven, sbt or other build tools, they will handle the dependencies transparently. Did you just copy smile jars to your project?

byTianHai commented 1 month ago

Thank you for your help,I added ommons-csv