Class CsvData


  • public class CsvData
    extends Object
    Represents the entire content of a CSV file. The file may consist of an optional header line and any number of data lines and (possibly) also comment lines. Comment lines may or may not be stored. Child classes add specific semantics for a particula type of CSV files.
    • Field Detail

      • header

        public String header
        The header line of the CSV file. It is not analyzed, but stored, and can be printed later. A file may or may not have a header line; to decide if there is one, we use a cludge: if the first letter of the first line is a digit, it's not a header, otehrwise it is
      • entries

        public CsvData.LineEntry[] entries
        All data lines, and possibly also comment lines, from the file
    • Constructor Detail

      • CsvData

        public CsvData​(File csvFile,
                       boolean neverHeader,
                       boolean keepComments,
                       int[] legalLengths)
                throws IOException,
                       IllegalInputException
        Creates a CsvData object from the content of a CSV file.
        Parameters:
        csvFile - File to read
        neverHeader - If true, we don't expect the input file to connect a header; the file only should have data lines and optional comment lines. If false, we look at the first line of the file to figure if it's a header line or data line or comment line, and process it appropriately.
        keepComments - If true, comment lines from the input file are stored in the object being created; otherwise, they are discarded.
        legalLengths - If this is not null, it specifies how many columns the file's lines may contain. For example, {4,6} means that the lines must contain 4 or 6 columns.
        Throws:
        IOException
        IllegalInputException