User Ratings
Rate This Project
Login To Rate This Project
Featured Reviews
Highest Rated
4 out of 5 starsPlease upload this to Maven Central Repository! Thanks!
Lowest Rated
1 out of 5 starsGot a Error while trying to use CSVtoBean class
Caused by: java.lang.NullPointerException
at au.com.bytecode.opencsv.bean.HeaderColumnNameMappingStrategy.createBean(Unknown Source)
at au.com.bytecode.opencsv.bean.CsvToBean.processLine(Unknown Source)
... 2 more
Testing Code:
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.List;
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.bean.ColumnPositionMappingStrategy;
import au.com.bytecode.opencsv.bean.CsvToBean;
public class OpenCSVTest {
/**
* @param args
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException {
/* Offer is a simple POJO class */
ColumnPositionMappingStrategy<Offer> colStrt = new ColumnPositionMappingStrategy<Offer>();
CsvToBean<Offer> c2b = new CsvToBean<Offer>();
CSVReader reader = new CSVReader(new FileReader("C:/offer.csv"));
List<Offer> offerList = c2b.parse(colStrt, reader);
for (Offer offer: offerList) {
System.out.println(offer.toString());
}
}
}
User Reviews
-
5 out of 5 starsThe RFC4180 parser works like a charm to read and write CSV. On top of that I got quick and great support from developers. Awesome!
-
5 out of 5 starsExcellent
-
5 out of 5 starsFast and easy
-
5 out of 5 starswhy are you guys hardcoded "null" while writing object to csv. anyspecif reason? In BeanToCSV class for (Method getter : getters) { /* 128 */ Object value = getter.invoke(bean, (Object[])null); /* 129 */ if (value == null) /* 130 */ values.add("null"); /* */ else { /* 132 */ values.add(value.toString()); /* */ }
-
5 out of 5 starsLibrary does exactly what it should do. Quick response from developers.
-
1 out of 5 starsI would like to use, but it's buggy. Try to save this> writer.writeNext(new String[]{"te\\\"st", "test"}); And try to read... Csv reader not able to read this file... Furthermore, unable to use on java 6 projects.
-
5 out of 5 starsDe-facto standard for parsing CSV.
-
4 out of 5 starsFor those wondering where to find this on Maven Central, the package name was changed to com.opencsv (see the news item "OpenCSV 3.1 is out in maven central!"). Add something like this your pom. <dependency> <groupId>com.opencsv</groupId> <artifactId>opencsv</artifactId> <version>3.1</version> </dependency>
-
4 out of 5 starsPlease upload this to Maven Central Repository! Thanks!
-
4 out of 5 starsPros: Quick and easy way to read CSV. We use it from Play framework (trough a scala wrapper) to read bulk user data. Cons: There some issues with quotes, etc. No progress on that since 2012.
-
5 out of 5 starsvery good project, thanks!
-
5 out of 5 starsIt saves my time. highly recommended
-
5 out of 5 starsOpencsv works great for me.
-
5 out of 5 starsGood and useful software
-
5 out of 5 starsa nice project but is it still moving on?
-
5 out of 5 starsOpencsv works great. Recommended!
-
5 out of 5 starsReally nice realization.
-
5 out of 5 starsVery often, the first line in a CSV file contains the field names. I created a little function that takes the list of lines as returned by Open CSV, and converts it to a list of maps, based on these field names. /** * @param lines a list of N CSV lines, as returned from reader.readAll(). * <p>The first line is assumed to be a header line, containing field names. * @return a list of (N-1) maps, one for each non-header line, with a map from the field name to its value. */ public static List<Map<String,String>> linesToMaps(List<String[]> lines) { if (lines.size()<1) throw new IllegalArgumentException("No heading line - no field names"); String[] fieldNames = lines.get(0); List<Map<String, String>> maps = new ArrayList<Map<String,String>>(); for (int iLine=1; iLine<lines.size(); ++iLine) { String[] line = lines.get(iLine); Map<String,String> map = new LinkedHashMap<String,String>(); // use linked hash map to keep the field order for (int iField=0; iField<line.length; ++iField) map.put(fieldNames[iField], line[iField]); maps.add(map); } return maps; }
-
5 out of 5 starsvery fast parser with good algorithm
-
5 out of 5 starsI use this software. Thank you for your work.
-
5 out of 5 starsStraight forward SIMPLE user interface.
-
5 out of 5 starsVery very good. Using for a long time.
-
5 out of 5 starsalways reliable. One of the first utilities I load on every new PC.
-
5 out of 5 starsGood work, thanks!
-
5 out of 5 starsVery good project. Try the beta for Windows, its freaking fast.