英文:
Univocity Parser in Java, parsing the CSV based on a particular column
问题
我对Univocity解析器还不太了解,我想知道是否有任何方法可以根据特定列的值解析csv文件,考虑到我想解析的CSV文件的大小,我希望根据日期属性来解析它。(例如:如果日期是2020年1月1日,那么只解析那些日期值与给定值匹配的行,即2020年1月1日)
如果您能就此问题提供任何见解,我将不胜感激。
我真的很感谢如果有人能够为我提供有关所述问题的任何见解。
谢谢,
Ria
英文:
I am quite new to Univocity Parser and I want to know if there is any way I can parse the csv file based on a value of particular column, considering the size of CSV I want to parse it based on a date attribute.(For Ex: if date is 1/1/2020 then parse only those rows that has date value matches with given value, i.e., 1/1/2020)
I will really appreciate if you can provide me any insight regarding this.
I really appreciate if someone can provide me any insight with the stated problem.
Thankyou,
Ria
答案1
得分: 0
parser.beginParsing(new FileReader(new File("abc.csv")));
int count = 0;
String[] row;
List<AttributesField> beanss = new ArrayList<>();
while ((row = parser.parseNext()) != null) {
AttributesField af = rowProcessor.createBean(row, parser.getContext());
row = af.getCommitted_at().split(" ");
if (row[0].compareTo("2013-11-13") <= 0) {
beanss.add(af);
}
}
英文:
parser.beginParsing(new FileReader(new File("abc.csv")));
int count=0;
String[] row;
List<AttributesField> beanss= new ArrayList<>();
while((row=parser.parseNext())!= null)
{
AttributesField af=rowProcessor.createBean(row, parser.getContext());
row=af.getCommitted_at().split(" ");
if(row[0].compareTo("2013-11-13") <=0) //Hardcode the date: return a.compareTo(d) * d.compareTo(b) > 0;
{
beanss.add(af);
}
}
答案2
得分: 0
Just filter and skip rows you don't need.
This is very easy since univocity provides iterative approach.
英文:
Just filter and skip rows you don't need.
This is very easy since univocity provides iterative approach.
专注分享java语言的经验与见解,让所有开发者获益!
评论