package cn.quant.andy;

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVRecord;
import org.junit.Test;

import java.io.FileReader;
import java.io.Reader;

/**
 * Created by Administrator on 2021/7/15 0015.
 */
public class CVSTest {

    @Test
    public void read() {
        try {
            Reader in = new FileReader("D:\\workspace\\quant-andy\\1.0.0\\quant-andy-server\\template\\wx_2021-06-01_2021-06-30.csv");
//            Iterable<CSVRecord> records = CSVFormat.EXCEL.withHeader().parse(in);
            Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(in);

            int i = 1;
            for (CSVRecord record : records) {
                StringBuilder builder = new StringBuilder();
                builder.append(i++).append("  ");
                builder.append(record.get(0)).append("  ");
                builder.append(record.get(1)).append("  ");
                builder.append(record.get(2)).append("  ");
                builder.append(record.get(3)).append("  ");
                builder.append(record.get(4)).append("  ");
                builder.append(record.get(5)).append("  ");
                builder.append(record.get(6)).append("  ");
                builder.append(record.get(7));
                System.out.println(builder.toString());
            }

            System.currentTimeMillis();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
