com.github.chen0040.glm.utils.CsvUtils Maven / Gradle / Ivy
package com.github.chen0040.glm.utils;
import com.github.chen0040.glm.data.DataRow;
import com.github.chen0040.glm.data.BasicDataRow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* Created by xschen on 1/5/2017.
*/
public class CsvUtils {
public static final String quoteSplitPM = "(?=([^\"]*\"[^\"]*\")*[^\"]*$)";
private static final Logger logger = LoggerFactory.getLogger(CsvUtils.class);
public static double atof(String s)
{
double d = Double.valueOf(s).doubleValue();
if (Double.isNaN(d) || Double.isInfinite(d))
{
System.err.print("NaN or Infinity in input\n");
System.exit(1);
}
return(d);
}
public static int atoi(String s)
{
int value = 0;
try {
value = Integer.parseInt(s);
}catch(NumberFormatException ex){
value = 0;
}
return value;
}
public static List