Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1c7a991
[CSV-201] Do not use RuntimeException in CSVParser.iterator().new
garydgregory Oct 25, 2016
fbc11c2
Add starter TravisCI configuration.
garydgregory Nov 16, 2016
acea0da
Add badges.
garydgregory Nov 19, 2016
3a8b735
commons-parent 40 -> 41.
garydgregory Nov 26, 2016
74d1140
Use Jacoco instead per config file.
garydgregory Nov 26, 2016
013dd9d
GroupId is duplicate of parent groupId.
garydgregory Nov 26, 2016
6dffab1
See if Travis can pick up parent POM SNAPSHOT to validate the parent
garydgregory Nov 26, 2016
64c8003
Coveralls badge fix.
garydgregory Nov 26, 2016
dee5125
Update version in Maven coordinates.
garydgregory Nov 26, 2016
20c6f33
Set parent POM back to 41.
garydgregory Nov 26, 2016
360998e
Trying to get Travis CI to pass coverage Jacoco reports to Coveralls.
garydgregory Nov 26, 2016
fa07e5e
Add -B -V to Maven invocation.
garydgregory Nov 26, 2016
b5c8240
Profile kicks in automatically on Travis.
garydgregory Nov 26, 2016
359e9cd
Actually do use the profile because the snapshot parent should not
garydgregory Nov 26, 2016
639b014
Edit (format nit) to kick off new Travis build to pick up new parent POM
garydgregory Nov 26, 2016
17902b8
Edit (format nit) to kick off new Travis build to pick up new parent POM
garydgregory Nov 26, 2016
92b4376
Go back to parent POM 41. Next will be preparing a RC for parent POM 42.
garydgregory Nov 26, 2016
0ec08e4
Add JiraCsv198Test.
garydgregory Dec 1, 2016
18ed616
Fix compiler warnings.
garydgregory Dec 1, 2016
9afec3e
Rename test package org.apache.commons.csv.bugs to
garydgregory Dec 1, 2016
f96adf2
[CSV-205]
garydgregory Dec 23, 2016
b1e5d93
Update commons-parent from 41 to 42.
garydgregory Jan 4, 2017
a775784
Javadoc fix.
garydgregory Feb 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

language: java
sudo: false

jdk:
- openjdk7
- oraclejdk7
- oraclejdk8

after_success:
- mvn -B -V -Ptravis-jacoco clean test jacoco:report coveralls:report
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ Apache Commons CSV
The Apache Commons CSV library provides a simple interface for reading and writing
CSV files of various types.

[![Build Status](https://travis-ci.org/apache/commons-csv.svg?branch=master)](https://travis-ci.org/apache/commons-csv)
[![Coverage Status](https://coveralls.io/repos/github/apache/commons-csv/badge.svg?branch=master)](https://coveralls.io/github/apache/commons-csv?branch=master)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-csv/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-csv/)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

Documentation
-------------

Expand All @@ -63,7 +68,7 @@ Alternatively you can pull it from the central Maven repositories:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.3</version>
<version>1.4</version>
</dependency>
```

Expand Down
33 changes: 16 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
<version>40</version>
<version>42</version>
</parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.5-SNAPSHOT</version>
<name>Apache Commons CSV</name>
Expand Down Expand Up @@ -414,9 +413,9 @@ CSV files of various types.
</dependency>

<dependency>
<groupId>net.sourceforge.javacsv</groupId>
<artifactId>javacsv</artifactId>
<version>2.0</version>
<groupId>net.sourceforge.javacsv</groupId>
<artifactId>javacsv</artifactId>
<version>2.0</version>
<scope>test</scope>
</dependency>

Expand Down
2 changes: 2 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
<action issue="CSV-193" type="fix" dev="ggregory" due-to="Matthias Wiehl">Fix incorrect method name 'withFirstRowAsHeader' in user guide.</action>
<action issue="CSV-171" type="fix" dev="ggregory" due-to="Gary Gregory, Michael Graessle, Adrian Bridgett">Negative numeric values in the first column are always quoted in minimal mode.</action>
<action issue="CSV-187" type="update" dev="ggregory" due-to="Gary Gregory">Update platform requirement from Java 6 to 7.</action>
<action issue="CSV-201" type="update" dev="ggregory" due-to="Benedikt Ritter, Gary Gregory">Do not use RuntimeException in CSVParser.iterator().new Iterator() {...}.getNextRecord()</action>
<action issue="CSV-189" type="add" dev="ggregory" due-to="Peter Holzwarth, Gary Gregory">CSVParser: Add factory method accepting InputStream.</action>
<action issue="CSV-190" type="add" dev="ggregory" due-to="Gary Gregory">Add convenience API CSVFormat.print(File, Charset)</action>
<action issue="CSV-191" type="add" dev="ggregory" due-to="Gary Gregory">Add convenience API CSVFormat.print(Path, Charset)</action>
<action issue="CSV-192" type="add" dev="ggregory" due-to="Gary Gregory">Add convenience API CSVParser.parse(Path, Charset, CSVFormat)</action>
<action issue="CSV-205" type="add" dev="ggregory" due-to="Gary Gregory">Add convenience API CSVFormat#printer() to print to System.out</action>
</release>
<release version="1.4" date="2016-05-28" description="Feature and bug fix release">
<action issue="CSV-181" type="update" dev="ggregory" due-to="Gary Gregory">Make CSVPrinter.print(Object) GC-free.</action>
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/apache/commons/csv/CSVFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,22 @@ public CSVPrinter print(final Appendable out) throws IOException {
return new CSVPrinter(out, this);
}

/**
* Prints to the {@link System#out}.
*
* <p>
* See also {@link CSVPrinter}.
* </p>
*
* @return a printer to {@link System#out}.
* @throws IOException
* thrown if the optional header cannot be printed.
* @since 1.5
*/
public CSVPrinter printer() throws IOException {
return new CSVPrinter(System.out, this);
}

/**
* Prints to the specified output.
*
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/org/apache/commons/csv/CSVParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public static CSVParser parse(final File file, final Charset charset, final CSVF
* call {@link #close()} on the parser, unless you close the {@code reader}.
* </p>
*
* @param reader
* a Reader containing CSV-formatted input. Must not be null.
* @param inputStream
* an InputStream containing CSV-formatted input. Must not be null.
* @param charset
* a Charset.
* @param format
Expand Down Expand Up @@ -501,10 +501,14 @@ public boolean isClosed() {
/**
* Returns an iterator on the records.
*
* <p>IOExceptions occurring during the iteration are wrapped in a
* RuntimeException.
* If the parser is closed a call to {@code next()} will throw a
* NoSuchElementException.</p>
* <p>
* An {@link IOException} caught during the iteration are re-thrown as an
* {@link IllegalStateException}.
* </p>
* <p>
* If the parser is closed a call to {@link Iterator#next()} will throw a
* {@link NoSuchElementException}.
* </p>
*/
@Override
public Iterator<CSVRecord> iterator() {
Expand All @@ -515,8 +519,8 @@ private CSVRecord getNextRecord() {
try {
return CSVParser.this.nextRecord();
} catch (final IOException e) {
// TODO: This is not great, throw an ISE instead?
throw new RuntimeException(e);
throw new IllegalStateException(
e.getClass().getSimpleName() + " reading next record: " + e.toString(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.csv.bugs;
package org.apache.commons.csv.issues;

import static org.junit.Assert.assertTrue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.csv.bugs;
package org.apache.commons.csv.issues;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down
47 changes: 47 additions & 0 deletions src/test/java/org/apache/commons/csv/issues/JiraCsv198Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.csv.issues;

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.Assert;
import org.junit.Test;

public class JiraCsv198Test {

private static final CSVFormat CSV_FORMAT = CSVFormat.EXCEL.withDelimiter('^').withFirstRecordAsHeader();

@Test
public void test() throws UnsupportedEncodingException, IOException {
InputStream pointsOfReference = getClass().getResourceAsStream("/CSV-198/optd_por_public.csv");
Assert.assertNotNull(pointsOfReference);
try (@SuppressWarnings("resource")
CSVParser parser = CSV_FORMAT.parse(new InputStreamReader(pointsOfReference, "UTF-8"))) {
for (CSVRecord record : parser) {
String locationType = record.get("location_type");
Assert.assertNotNull(locationType);
}
}
}

}
Loading