com.github.chen0040.data.utils.CsvUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-data-frame Show documentation
Show all versions of java-data-frame Show documentation
Some common patterns of data frame in Java
The newest version!
package com.github.chen0040.data.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
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
© 2015 - 2025 Weber Informatics LLC | Privacy Policy