Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C69F810F20 for ; Sun, 23 Jun 2013 14:03:26 +0000 (UTC) Received: (qmail 41845 invoked by uid 500); 23 Jun 2013 14:03:24 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 41580 invoked by uid 500); 23 Jun 2013 14:03:24 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 41510 invoked by uid 99); 23 Jun 2013 14:03:20 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 23 Jun 2013 14:03:20 +0000 Date: Sun, 23 Jun 2013 14:03:20 +0000 (UTC) From: "Gary Gregory (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CSV-93) Allow the handling of NULL values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CSV-93?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13691462#comment-13691462 ] Gary Gregory commented on CSV-93: --------------------------------- Good points. I am replacing my patch with a new version. The property name is now 'nullInputString' and after that I'd rename the property 'nullToString' to 'nullOutputString'. {code:java} /** * Converts the given String to {@code null} when reading records. * * @param nullInputString * the String to convert to {@code null} when reading records. No substitution occurs if {@code null} * * @return This builder with the the specified input record separator */ public CSVFormatBuilder withNullInputString(final String nullInputString) { this.nullInputString = nullInputString; return this; } /** * Gets the String to convert to {@code null} when reading records. * * @return the String to convert to {@code null} when reading records. No substitution occurs if {@code null} */ public String getNullInputString() { return nullInputString; } {code} > Allow the handling of NULL values > --------------------------------- > > Key: CSV-93 > URL: https://issues.apache.org/jira/browse/CSV-93 > Project: Commons CSV > Issue Type: Improvement > Components: Documentation, Parser, Printer > Affects Versions: 1.0 > Reporter: Georg Tsakumagos > Attachments: CSV-93.diff, patch.txt > > > h5. Requirement > To use the CSV parser and printer for SQL Dumps it would be nice if they could handle *null* values. > h5. Specification > To distinguish between an *empty* or *null* value empty values always gets quoted to denote an empty string. The absence of an quote denotes a *null* value > h5. Configuration > To activate the behavior call the method _withNullObjectPatternEnabled_ of the _CSVFormat_ with parameter _true_. > h5. Modifications > See attached patch. > h5. Example > This example using as base the _DEFAULT_ _CSVFormat_ modified by the NullObjectPattern behavior. > || Array-Data || CSV-Data || > | \{null,"","A"," "\}; |,"A",""," " | > | \{"",null,"A"," "\} |"",,"A"," " | > | \{"","A",null\} |"","A", | > h5. NULL in DBMS proprietary CSV formats > || Product || Strategy || Documentation / Link || > | PostgreSQL | If NULL should be preserved all non NULL values gets quoted | [PostgreSQL 8.1 Manual|http://www.postgresql.org/docs/8.1/static/sql-copy.html] | > | MySQL | NULL Values will be replaced by the letters NULL or escaped by \n | not found, verified with MySQL Workbench | > | MS SQL | NULL values will be exported as empty strings (no quotes). Strings will be quoted if needed. Import can interpret them as null | [MSDN|http://msdn.microsoft.com/en-us//library/ms187887] | > | Oracle | NULL Values will be replaced by the letters NULL | [Manual|http://docs.oracle.com/cd/B25329_01/doc/admin.102/b25107/impexp.htm] | -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira