Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 80700200BDE for ; Thu, 1 Dec 2016 22:29:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7EFAC160B05; Thu, 1 Dec 2016 21:29:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C7945160B10 for ; Thu, 1 Dec 2016 22:28:59 +0100 (CET) Received: (qmail 74793 invoked by uid 500); 1 Dec 2016 21:28:58 -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 74530 invoked by uid 99); 1 Dec 2016 21:28:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2016 21:28:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 9D0282C2A66 for ; Thu, 1 Dec 2016 21:28:58 +0000 (UTC) Date: Thu, 1 Dec 2016 21:28:58 +0000 (UTC) From: "Gary Gregory (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CSV-198) Cannot parse file by header with custom delimiter on Java 1.6 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 01 Dec 2016 21:29:00 -0000 [ https://issues.apache.org/jira/browse/CSV-198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15713134#comment-15713134 ] Gary Gregory commented on CSV-198: ---------------------------------- I added {{org.apache.commons.csv.issues.JiraCsv198Test}} and cannot reproduce with Java 1.7.0_79 and 1.8.0_112. > Cannot parse file by header with custom delimiter on Java 1.6 > ------------------------------------------------------------- > > Key: CSV-198 > URL: https://issues.apache.org/jira/browse/CSV-198 > Project: Commons CSV > Issue Type: Bug > Components: Parser > Affects Versions: 1.4 > Environment: Java 1.6, Windows > Reporter: Tadhg Pearson > > Reading a CSV file from the parser using the header line results in "IllegalArgumentException: Mappng for not found" - even when the column exists in the file. In this case, we are using Java 1.6 and the file uses the ^ symbol to delimit columns. This works correctly in Java 7 & Java 8. > The code required to reproduce the issue is below. You can find the optd_por_public.csv file referenced at https://raw.githubusercontent.com/opentraveldata/opentraveldata/master/opentraveldata/optd_por_public.csv > It will need to be on the classpath to run the unit test. Hope that helps, Tadhg > You should get the following output > -------------------------------------- > {code} > java.lang.IllegalArgumentException: Mapping for location_type not found, expected one of [iata_code,icao_code,faa_code,is_geonames,geoname_id,envelope_id,name,asciiname,latitude,longitude,fclass,fcode,page_rank,date_from,date_until,comment,country_code,cc2,country_name,continent_name,adm1_code,adm1_name_utf,adm1_name_ascii,adm2_code,adm2_name_utf,adm2_name_ascii,adm3_code,adm4_code,population,elevation,gtopo30,timezone,gmt_offset,dst_offset,raw_offset,moddate,city_code_list,city_name_list,city_detail_list,tvl_por_list,state_code,location_type,wiki_link,alt_name_section,wac,wac_name] > at org.apache.commons.csv.CSVRecord.get(CSVRecord.java:104) > at com.amadeus.ui.CSVRecordTest.test(CSVRecordTest.java:31) > {code} > ------------ > {code:java} > import static org.junit.Assert.assertNotNull; > import java.io.IOException; > import java.io.InputStream; > import java.io.InputStreamReader; > import java.io.UnsupportedEncodingException; > import org.apache.commons.csv.CSVFormat; > import org.apache.commons.csv.CSVParser; > import org.apache.commons.csv.CSVRecord; > import org.junit.Test; > public class CSVRecordTest { > private static final CSVFormat CSV_FORMAT = CSVFormat.EXCEL.withDelimiter('^').withFirstRecordAsHeader(); > > @Test > public void test() throws UnsupportedEncodingException, IOException { > InputStream pointsOfReference = getClass().getResourceAsStream("/optd_por_public.csv"); > CSVParser parser = CSV_FORMAT.parse(new InputStreamReader(pointsOfReference, "UTF-8")); > for (CSVRecord record : parser) { > String locationType = record.get("location_type"); > assertNotNull(locationType); > } > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)