Class ImportCSV

java.lang.Object
edu.wisc.game.util.ImportCSV

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

See ... for the file format.

Author:
Vladimir Menkov
  • Constructor Details

    • ImportCSV

      public ImportCSV()
  • Method Details

    • splitCSVTrim

      public static String[] splitCSVTrim(String s) throws IllegalInputException
      Throws:
      IllegalInputException
    • 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)
    • escapeAndwriteToFile

      public static void escapeAndwriteToFile(String[][] lines, File f) throws IOException
      Throws:
      IOException