Class EcsvHeader

java.lang.Object
uk.ac.starlink.ecsv.EcsvHeader

public class EcsvHeader extends Object
Represents the part of an ECSV file preceding the actual data lines.
Since:
28 Apr 2020
Author:
Mark Taylor
  • Constructor Details

    • EcsvHeader

      public EcsvHeader(String[] yamlLines, String namesLine)
      Constructor.
      Parameters:
      yamlLines - lines of YAML containing header information; these lines exclude the leading "# " characters found in the ECSV file
      namesLine - first non-YAML line in the ECSV file, which is supposed to contain a redundant list of column names
  • Method Details

    • getYamlLines

      public String[] getYamlLines()
      Returns the lines of YAML containing header information. Leading "# " characters are not included.
      Returns:
      YAML text as array of lines
    • getNamesLine

      public String getNamesLine()
      Returns the CSV-formatted line supposed to contain column names.
      Returns:
      column names line
    • readHeader

      public static EcsvHeader readHeader(LineReader rdr) throws IOException, EcsvFormatException
      Constructs an EcsvHeader instance by reading lines from a file.
      Parameters:
      rdr - line reader returning input lines
      Returns:
      header instance
      Throws:
      IOException
      EcsvFormatException
    • isMagic

      public static boolean isMagic(byte[] intro)
      Indicates whether a byte sequence indicates the start of an ECSV file.
      Parameters:
      intro - first few bytes of a file
      Returns:
      true iff file looks like ECSV