Search in sources :

Example 1 with CsvReadOptions

use of tech.tablesaw.io.csv.CsvReadOptions in project symja_android_library by axkr.

the class SemanticImportString method evaluate.

@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
    if (!(ast.arg1() instanceof IStringX)) {
        return F.NIL;
    }
    IStringX arg1 = (IStringX) ast.arg1();
    try {
        String contents = arg1.toString();
        char delimiter = determineDelimiter(contents);
        CsvReadOptions.Builder builder = CsvReadOptions.builderFromString(contents).separator(delimiter);
        CsvReadOptions options = builder.build();
        Table table = Table.read().usingOptions(options);
        return ASTDataset.newTablesawTable(table);
    } catch (Exception rex) {
        LOGGER.log(engine.getLogLevel(), "SemanticImportString ", rex);
        return F.NIL;
    }
}
Also used : Table(tech.tablesaw.api.Table) CsvReadOptions(tech.tablesaw.io.csv.CsvReadOptions) IStringX(org.matheclipse.core.interfaces.IStringX)

Aggregations

IStringX (org.matheclipse.core.interfaces.IStringX)1 Table (tech.tablesaw.api.Table)1 CsvReadOptions (tech.tablesaw.io.csv.CsvReadOptions)1