简体   繁体   English

com.fasterxml.jackson.dataformat.csv.CsvMapper:限制较少的模式?

[英]com.fasterxml.jackson.dataformat.csv.CsvMapper: less restrictive mode?

CSV ("comma separated values") files, like many data sources, can have aberrations: CSV(“逗号分隔值”)文件,与许多数据源一样,可能有偏差:

  • More or fewer fields than there are columns.字段数多于或少于列数。
  • Field values that might present challenges (Eg, containing the field-separator).可能带来挑战的字段值(例如,包含字段分隔符)。

Is there some way to configure the jackson CsvMapper so that is operates more liberally: ie, is less restrictive with regard to parsing the data records in CSV files?有没有什么方法可以配置 jackson CsvMapper ,使其运行更自由:即,在解析 CSV 文件中的数据记录方面限制较少?

I suggest looking into the configuration options for com.fasterxml.jackson.dataformat.csv.CsvMapper .我建议查看com.fasterxml.jackson.dataformat.csv.CsvMapper的配置选项。 The setup below helped me deal with trailing, unmatched columns (in my case, one or more commas with no field content between them):下面的设置帮助我处理了尾随的、不匹配的列(在我的例子中,一个或多个逗号之间没有字段内容):

CsvMapper csvMapper = (new CsvMapper()).configure(Feature.IGNORE_TRAILING_UNMAPPABLE, true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM