CSVwriter support JDBC column name mapper+filter
Brought to you by:
aruckerjones,
sconway
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).
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);
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:
--
Scott Conway
scott.conway@gmail.com
http://www.conwayfamily.name
Related
Patches:
#51Applied in 3.7 version