Comments (8)
Inherited methods work. Try the following example:
public class Github_45 {
public static abstract class Named {
@Parsed(field = "Code")
private String code;
@Parsed(field = "Name")
private String name;
public Named(){
}
public String toString(){
return code + ": " + name;
}
}
public static class Department extends Named {}
public static class Employee extends Named {}
public static void main(String ... args){
CsvParserSettings settings = new CsvParserSettings();
BeanListProcessor<Employee> list = new BeanListProcessor<Employee>(Employee.class);
settings.setRowProcessor(list);
CsvParser parser = new CsvParser(settings);
parser.parse(new StringReader("Code,Name\nA,B\nC,D"));
for(Employee e : list.getBeans()){
System.out.println(e);
}
}
}
You are having trouble because your classes are not public and the parser can't instantiate them.
from univocity-parsers.
Jeronimo, thanks for your prompt reply. I took your sample, copied it to a file and ran the code. I got:
null: null
null: null
null: null
As for my original code, I had only provided a quick sample, not the actual classes. Actual classes are all public. You can download the full sample project from http://www.filedropper.com/csv-mapping_1 and run it with Maven as mvn clean test
. You will find that the tests fail with the latest version (1.5.6) as well as the one I am using (1.4.0). I am running these on a Windows 7 Professional, 64-bit machine (if that matters).
from univocity-parsers.
See line 75 in BeanConversionProcessor in release 1.5.6 and compare it with the code on the master
branch. On the master
, the code attempts to go up the class hierarchy looking for fields to parse, whereas it doesn't do that in release 1.5.6.
That explains why the released code does not pick up inherited fields. Most likely, your sample must have been run against the master
, which is why it would have succeeded.
from univocity-parsers.
Thanks Manish. You are correct. Use version 2.0.0-SNAPSHOT to get this fixed. We'll release the final 2.0.0 version within a month or so.
from univocity-parsers.
Cool, I am grateful for having stumbled across this library. I am using it in a web app that supports uploading .xls and .csv files. The difference in performance between .xls and .csv parsing is absolutely mind-blowing, and our advanced users who upload .csv files are patently thrilled.
Is it possible for you to release an intermediate version (may be 1.5.7) with just this fix? Our CSV upload feature is currently in limited beta and users are baying to release it across the application. Getting a fix will allow us to release CSV uploads to a wider audience.
from univocity-parsers.
For more immediate needs, we offer paid support and will take care of your problem straight away.
from univocity-parsers.
Jeronimo, do you have a release date for 2.0.0?
from univocity-parsers.
Will be around January, 2016. We are working on a lot of stuff that integrates with univocity-parsers-2.0.0 and some development is still to be made on it.
from univocity-parsers.
Related Issues (20)
- RetryableErrorHandler.handleConversionError throws ArrayIndexOutOfBoundsException HOT 1
- Tutorial site is not available HOT 1
- Wrong result for FixedWidthParser HOT 1
- CSV Reader does not escape ASCII control characters
- Differentiating NULL, EMPTY-STRING and SPACE in CSV files from a ResultSet
- New Realese
- The headers cache (StringCache) cause a memory leak
- Incorrect header parsing
- Add small (4 Gb limit) clob support
- `parseRecord(bean)` does not work
- parseRow not working in (CentOS Linux release 7.6.1810 (Core) )
- Integrating uniVocity into OSS-Fuzz
- Website unavailable HOT 1
- is there is any way to get the MaxDataColumnCount in the TSV File which has no text Qualifier and Headers.
- Incorrect column pruning HOT 1
- CsvWriterSettings - add option to not create the final line separator
- AbstractCharInputReader throws ArrayIndexOutOfBoundsException when buffer starts with whitespace
- Date format issue "MM/dd/YYYY" in csv download file
- THIS REPO IS ABANDONED – IT IS USELESS TO OPEN ISSUES OR PULL REQUESTS HOT 8
- Memory not released after processing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from univocity-parsers.