package org.canova.api.records.reader.impl;



import org.canova.api.io.data.Text;
import org.canova.api.writable.Writable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Simple csv record reader.
 *
 * @author Adam Gibson
 */
public class CSVRecordReader extends LineRecordReader {


    @Override
    public Collection<Writable> next() {
        Text t =  (Text) super.next().iterator().next();
        String val = new String(t.getBytes());
        String[] split = val.split(",");
        List<Writable> ret = new ArrayList<>();
        for(String s : split)
            ret.add(new Text(s));
        return ret;
    }
}

@@ -322,64 +322,996 @@
 r %7B%0A
-%0A%0A    @Override%0A    public Collection%3CWritable%3E next() %7B
+    private boolean skippedLines = false;%0A    private int skipNumLines = 0;%0A    private String delimiter = %22,%22;%0A%0A    /**%0A     * Skip first n lines%0A     * @param skipNumLines the number of lines to skip%0A     */%0A    public CSVRecordReader(int skipNumLines) %7B%0A         this(skipNumLines,%22,%22);%0A    %7D%0A%0A    /**%0A     * Skip lines and use delimiter%0A     * @param skipNumLines the number of lines to skip%0A     * @param delimiter the delimiter%0A     */%0A    public CSVRecordReader(int skipNumLines,String delimiter) %7B%0A        this.skipNumLines = skipNumLines;%0A        this.delimiter = delimiter;%0A    %7D%0A%0A    public CSVRecordReader() %7B%0A        this(0,%22,%22);%0A    %7D%0A%0A    @Override%0A    public Collection%3CWritable%3E next() %7B%0A        if(!skippedLines && skipNumLines %3E 0) %7B%0A            for(int i = 0; i %3C skipNumLines; i++) %7B%0A                if(!hasNext()) %7B%0A                    return new ArrayList%3C%3E();%0A                %7D%0A                super.next();%0A            %7D%0A            skippedLines = true;%0A        %7D
 %0A   
@@ -1446,19 +1446,25 @@
 l.split(
-%22,%22
+delimiter
 );%0A     
@@ -1590,16 +1590,17 @@
 rn ret;%0A
+%0A
     %7D%0A%7D%0A

add configuration for csv