Super CSV, another open source CSV API for Java, supports this functionality out of the box. See the example on partial reading.
It uses the header (i.e. first row) to determine what fields to map to the bean - so will be able to read both of your files fine.
If you were using other types in your bean (dates, integers, etc) instead of just Strings, then Super CSV can do all the required conversions/transformations for you with it's cell processor API.
For example, the following code would read both of your files, but only populate the fields that exist in the CSV file.
ICsvBeanReader beanReader = null;
try {
beanReader = new CsvBeanReader(new FileReader(CSV_FILENAME),
CsvPreference.STANDARD_PREFERENCE);
// header is used to map CSV column -> field in bean
final String[] header = beanReader.getHeader(true);
Data data;
while( (data = beanReader.read(Data.class, header)) != null ) {
System.out.println(String.format("id=%s, name=%s, phone=%s",
data.getId(), data.getName(), data.getPhone()));
}
}
finally {
if( beanReader != null ) {
beanReader.close();
}
}