Class ImportCSV


  • public class ImportCSV
    extends Object
    Methods responsible for parsing CSV files.

    See ... for the file format.

    Author:
    Vladimir Menkov
    • Constructor Detail

      • ImportCSV

        public ImportCSV()
    • Method Detail

      • splitCSV

        public static String[] splitCSV​(String s)
                                 throws IllegalInputException
        Converts a single string (such as a line of CSV file) into an array of strings. Splits a string by commas, with a primitive attempt to take care of nested quotes. This method interprets "" as an escaped ". This is appropriate, for example, for CSV files saved from Google Spreadsheets.
        Throws:
        IllegalInputException
      • escape

        public static String escape​(String s)
        Process a string for writing into a CSV file (as the content of a single cell). Escapes any double quotes the string contains, and surrounds it with double quotes if needed. We also replace multiple spaces with single spaces.
      • escape

        public static String escape​(String[] ss)
        Processes all Strings for writing into a CSV file (as one line)