Menu

#51 CSVwriter support JDBC column name mapper+filter

Unstable (example)
closed-accepted
patch (1)
5
2016-06-07
2015-12-02
No

I have developed a small patch which allows export of an SQL table filtering column names; excluding some columns and setting header names for the CSV file at the same time.

This is useful, because I need to export a subset of data for external publication from a production database; where I cannot change the column names - and I do not want to make yet another copy.

I have attached the patch (please forgive any errors, this is my first contribution to SF).

1 Attachments

Related

Patches: #51

Discussion

  • Thomas Berger

    Thomas Berger - 2015-12-02

    private String[] columnNames = {"COL1", "COL2"};// SQL table columns
    private String[] headerNames = {"Item.Name", "Item.Value"};// CSV header

    CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(new File(csvFile)), "UTF-8"), ',', CSVWriter.DEFAULT_QUOTE_CHARACTER);
    MyResultSetHelperService jdbcMapper = new MyResultSetHelperService();
    jdbcMapper.setColumns(colNames, colHeader);
    writer.setResultService(jdbcMapper);

     
    • Scott Conway

      Scott Conway - 2015-12-02

      Hello Thomas - sorry for the delayed response but with the holidays here I
      am not getting much time with opencsv. I will try and take a look at your
      patch before the Xmas holidays and get back with you if I have any
      questions are concerns.

      :)

      On Wed, Dec 2, 2015 at 8:41 AM, Thomas Berger bergert@users.sf.net wrote:

      private String[] columnNames = {"COL1", "COL2"};// SQL table columns
      private String[] headerNames = {"Item.Name", "Item.Value"};// CSV header

      CSVWriter writer = new CSVWriter(new OutputStreamWriter(new
      FileOutputStream(new File(csvFile)), "UTF-8"), ',',
      CSVWriter.DEFAULT_QUOTE_CHARACTER);
      MyResultSetHelperService jdbcMapper = new MyResultSetHelperService();
      jdbcMapper.setColumns(colNames, colHeader);
      writer.setResultService(jdbcMapper);


      Status: open
      Group: Unstable (example)
      Labels: patch
      Created: Wed Dec 02, 2015 02:41 PM UTC by Thomas Berger
      Last Updated: Wed Dec 02, 2015 02:41 PM UTC
      Owner: nobody
      Attachments:

      I have developed a small patch which allows export of an SQL table
      filtering column names; excluding some columns and setting header names for
      the CSV file at the same time.

      This is useful, because I need to export a subset of data for external
      publication from a production database; where I cannot change the column
      names - and I do not want to make yet another copy.

      I have attached the patch (please forgive any errors, this is my first
      contribution to SF).


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/opencsv/patches/51/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Scott Conway
      scott.conway@gmail.com
      http://www.conwayfamily.name

       

      Related

      Patches: #51

  • Scott Conway

    Scott Conway - 2016-06-07
    • status: open --> closed-accepted
    • assigned_to: Scott Conway
     
  • Scott Conway

    Scott Conway - 2016-06-07

    Applied in 3.7 version

     

Log in to post a comment.