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

      • entries

        public CsvData.LineEntry[] entries
        All data lines (except for, possibly, the first line), and possibly also comment lines, from the file
      • header

        public CsvData.BasicLineEntry header
        Unless noHeader=true, this is where we put the first line of the file. The leading '#', if present, is removed.
    • Constructor Detail

      • CsvData

        public CsvData​(File csvFile,
                       boolean noHeader,
                       boolean keepComments,
                       int[] legalLengths)
                throws IOException,
                       IllegalInputException
        Creates a CsvData object from the content of a CSV file.
        Parameters:
        csvFile - File to read
        noHeader - If true, we don't expect the input file to contain a header; the file only should have data lines and optional comment lines. (In reality, of course, the first line may still have header semantics, but it's up to the user of this class to separate and process it). 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