bounty将在5天后过期。回答此问题可获得+50声望奖励。Salman S希望引起更多人关注此问题。
如何通过在univocity中使用BatchedColumnProcessor来使用列Map?
CsvParserSettings settings = new CsvParserSettings();
settings.setProcessor(new BatchedColumnProcessor(5) {
@Override
public void batchProcessed(int rowsInThisBatch) {}
});
CsvParser parser = new CsvParser(settings);
就像我们在BeanListProcessor中使用的那样,并添加自定义列Map
BeanListProcessor<Product> rowProcessor = new BeanListProcessor<Product>(Product.class);
rowProcessor.setColumnMapping();
1条答案
按热度按时间ht4b089n1#
X1 M0 N1 X仅在X1 M1 N1 X第287期中提及一次,并在X1 E0 F1 X中说明,其应用于具有OpenCSV的X1 M2 N1 X。
该问题提到了“initial code to support github issue #287 - map column name to attribute“,并以
Github_287.java
为例因此,从2.8.0开始:
我发布了一个2.8.0-SNAPSHOT版本,它允许您从以下位置调用
getColumnMapper()
:嵌套类也是受支持的,你可以做如下的事情,其中name被隐藏在一个对象结构中(假设一个类Purchase有一个
Buyer
属性,而这个属性又有一个Contact
属性,name位于这个属性中):向文件写入或从文件阅读。Map器。方法到列名(“买方。联系人。全名”,“客户_名称”);
你也可以给予它一张Map: