Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package berlin.yuna.logic;
import berlin.yuna.model.CsvIndexRow;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.function.Consumer;
import static berlin.yuna.logic.CsvReader.csvReader;
public class ConsumeCSV {
/**
* @param file the path to the file - or path to a resource
* @param consumer consumer to progress the {@link berlin.yuna.model.CsvRow}
* @param separators column split parameter (no regex)
*/
public static void consumeCsv(final Path file, final Consumer consumer, final char... separators) {
consumeCsv(file, consumer, -1, separators);
}
/**
* @param file the path to the file - or path to a resource
* @param consumer consumer to progress the {@link berlin.yuna.model.CsvRow}
* @param skip lines to skip while reading csv
* @param separators column split parameter (no regex)
*/
public static void consumeCsv(final Path file, final Consumer consumer, final long skip, final char... separators) {
consumeCsv(file, consumer, skip, null, separators);
}
/**
* See example: {@link CsvReader#readAllRows(Path)}
*
* @param file The path to the file - or path to a resource
* @param consumer consumer to progress the {@link berlin.yuna.model.CsvRow}
* @param skip lines to skip while reading csv
* @param charset The charset to use for decoding the CSV file
* @param separators Splits the CSV rows at the given separator Included fallback: [',']
*/
public static void consumeCsv(final Path file, final Consumer consumer, final long skip, final Charset charset, final char... separators) {
consumeCsv(file, consumer, skip, charset, false, separators);
}
/**
* @param file The path to the file - or path to a resource
* @param consumer consumer to progress the {@link berlin.yuna.model.CsvRow}
* @param skip lines to skip while reading csv
* @param charset The charset to use for decoding the CSV file
* @param unzip On true detects and unzips the CSV file automatically
* @param separators Splits the CSV rows at the given separator Included fallback: [',']
*/
public static void consumeCsv(final Path file, final Consumer consumer, final long skip, final Charset charset, final boolean unzip, final char... separators) {
consumeCsv(file, consumer, skip, charset, unzip, false, separators);
}
/**
* @param file The path to the file - or path to a resource
* @param consumer consumer to progress the {@link berlin.yuna.model.CsvRow}
* @param skip lines to skip while reading csv
* @param charset The charset to use for decoding the CSV file
* @param unzip On true detects and unzips the CSV file automatically
* @param autoSep On true detects the separator automatically
* @param separators Splits the CSV rows at the given separator Included fallback: [',']
*/
public static void consumeCsv(final Path file, final Consumer consumer, final long skip, final Charset charset, final boolean unzip, final boolean autoSep, final char... separators) {
csvReader().skipLines(skip).charset(charset).separator(separators).unzip(unzip).autoSep(autoSep).consume(file, consumer);
}
private ConsumeCSV() {
}
}