https://github.com/j256/simplecsv
Simple Java CSV reading and writing library using Java annotations
https://github.com/j256/simplecsv
annotations csv java
Last synced: about 1 year ago
JSON representation
Simple Java CSV reading and writing library using Java annotations
- Host: GitHub
- URL: https://github.com/j256/simplecsv
- Owner: j256
- License: isc
- Created: 2014-11-23T22:18:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-03-25T09:18:51.000Z (almost 4 years ago)
- Last Synced: 2025-03-01T17:51:30.927Z (about 1 year ago)
- Topics: annotations, csv, java
- Language: Java
- Homepage: http://256stuff.com/sources/simplecsv/
- Size: 1.08 MB
- Stars: 25
- Watchers: 5
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
Simple Java CSV Reader / Writer
===============================
This package provides some Java classes to help with the reading and writing of CSV files using Java annotations.
* For more information, visit the [home page](http://256stuff.com/sources/simplecsv/).
* In the sourcecode there is a [simple working example program](http://256stuff.com/sources/simplecsv/docs/example-simple).
* Online documentation can be found off the home page including [full Javadocs](http://256stuff.com/sources/simplecsv/javadoc/simplecsv/).
* The source is available from the [git repository](https://github.com/j256/simplecsv). [](https://circleci.com/gh/j256/simplecsv) [](https://codecov.io/github/j256/simplecsv/)
* Maven packages are published via [](https://maven-badges.herokuapp.com/maven-central/com.j256.simplecsv/simplecsv/)
* Javadocs: [](https://javadoc.io/doc/com.j256.simplecsv/simplecsv)
Enjoy. Gray Watson
## Quick Example:
Define your entity with the fields marked with the @CsvColumn annotation, can also mark get/set methods:
public class Account {
@CsvColumn(columnName = "Name")
private String name;
@CsvColumn(columnName = "Account Number")
private long number;
...
}
Create a CSV processor for the Account class.
CsvProcessor csvProcessor = new CsvProcessor(Account.class);
Write out all of the accounts from a list of them to a CSV file with a header:
File csvFile = new File(CSV_FILE_PATH);
csvProcessor.writeAll(csvFile, accountList, true /* write header */);
This generates the following output:
"Name","Account Number"
"Bill Smith",1
"Foo Bar",2
"Jim Jimston",3
Now read those accounts back in with an optional error handler:
List readAccounts = csvProcessor.readAll(csvFile, null /* error handler */);
# Maven Configuration
* Maven packages are published via [](https://maven-badges.herokuapp.com/maven-central/com.j256.simplecsv/simplecsv/)
``` xml
com.j256.simplecsv
simplecsv
2.6
```
# ChangeLog Release Notes
See the [ChangeLog.txt file](src/main/javadoc/doc-files/changelog.txt).