Package org.gbif.utils.file.tabular
Class TabularFileMetadataExtractor
java.lang.Object
org.gbif.utils.file.tabular.TabularFileMetadataExtractor
Utility class to extract metadata
TabularFileMetadata from a tabular file.-
Method Summary
Modifier and TypeMethodDescriptionstatic TabularFileMetadataextractTabularFileMetadata(Path filePath) Extract metadata from a tabular file using a sample (defined byMAX_SAMPLE_SIZE) of the file.getDelimiterChar(List<String> sample) Given a sample of line, this method tries to determine the delimiter char used.
-
Method Details
-
extractTabularFileMetadata
public static TabularFileMetadata extractTabularFileMetadata(Path filePath) throws IOException, UnknownCharsetException Extract metadata from a tabular file using a sample (defined byMAX_SAMPLE_SIZE) of the file. The extraction process is based on the frequency of character in the sample using 3 different approaches. The method will not return any default value if no delimiter and/or quote character can be found in the sample. The caller should decide which default values should be used to read the file.- Parameters:
filePath- aPathpointing to a file (not a folder).- Returns:
- new
TabularFileMetadata, never null (but the content can be null). - Throws:
IOExceptionUnknownCharsetException
-
getDelimiterChar
Given a sample of line, this method tries to determine the delimiter char used.- Parameters:
sample-- Returns:
- the determined delimiter or Optional.empty if it can not be determined.
-