Class TabularFileMetadataExtractor

java.lang.Object
org.gbif.utils.file.tabular.TabularFileMetadataExtractor

Utility class to extract metadata TabularFileMetadata from a tabular file.
  • Method Details

    • extractTabularFileMetadata

      Extract metadata from a tabular file using a sample (defined by MAX_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 - a Path pointing to a file (not a folder).
      Returns:
      new TabularFileMetadata, never null (but the content can be null).
      Throws:
      IOException
      UnknownCharsetException
    • getDelimiterChar

      public static Optional<Character> getDelimiterChar(List<String> sample)
      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.