Uploaded image for project: 'Commons CSV'
  1. Commons CSV
  2. CSV-174

Adding methods to support JSON-CSV interchangeability and adding a class/methods to support direct cell modification

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Build

    Description

      I wish to introduce some major features in the Commons CSV that I found really necessary while dealing with CSV file parsing requirements of an ERP for a University.

      1.Custom Exceptions:
      Exceptions to be raised when incorrectly formatted CSVs are parsed specifying the row number mentioning reasons like incorrect number of columns.

      2. Export to JSON:
      PostgreSQL Supports direct import of JSON Code. So to insert data from a CSV into the database I had to first convert it to JSON and then make the insert. If we could have an option to do this directly it would be a lot more time saving.

      3.New Class CSVFile
      I wish to introduce a new class CSVFile which shall have the entire contents of the CSV stored in nested Array Lists.

      I shall have the following methods in the class:
      Constructors:
      void CSVFile(CSVParser);
      void CSVFile(Object [][],boolean has_headers);
      void CSVFile(JSON Array,boolean allow_blanks);
      void CSVFile(String text,String cell_delimiter,String line_delimiter,boolean force_headerSchema);

      Printers:
      String CSVFile.toString();
      JSONArray CSVFile.toJSONArray();
      Object[][] CSVFile.toArray();
      ResultSet CSVFile.toResultSet();
      ArrayList<Object[]> CSVFile.toArrayList();
      ArrayList<ArrayList<Object>> CSVFile.toNestedArrayList();
      String CSVFile.toString();

      Access:
      CSVFile.setColumnHeader(int col_number);
      String CSVFile.getCell(int row_number,String header);
      String CSVFile.getCell(int row_number,int col_number);
      CSVFile.setCell(int row_number,int col_number,String value);
      CSVFile.setCell(int row_number,String header,String value);
      CSVFile.getRowArray();
      JSONObject CSVFile.getRowJSON();

      Sorting:
      CSVFile.sort(Comparator());

      Extraction:
      CSVFile CSVFile.getColumns(Arraylist<String> headers);
      CSVFile CSVFile.getRows(extractor());
      @override
      public boolean include(CSVRecord record)

      { //if satisfies Condition then include return true; //else return false }

      Delete:
      void CSVFile.removeRow(int row_number);
      void CSVFile.remove Section(int start_row,int end_row);
      void CSVFile.CSVFile.removeRows(extractor());
      void CSVFile.removeColumn(int col_number);
      void CSVFile.removeColumn(String header);

      Attachments

        Activity

          People

            Unassigned Unassigned
            pintojoey@gmail.com Joey Pinto
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: