Questions tagged [univocity]

univocity provides CSV/TSV/text file parsers for Java. Use this tag for questions when using their parser and also include other tags to indicate what other issues or frameworks are involved

Univocity provides open-source parsers with a wide range of features to read data by fields, into JavaBeans; writing delimited files, routines to provide short-cuts to common steps, and handling heading rows.

See also

120 questions
1
vote
1 answer

Univocity - Parse single row into multiple beans

Is it possible to parse a single line into multiple beans based on index ranges Example: Line: "field1", "field2", "field3", ...., "field9" class ColumnsOneAndTwo { protected String field1; protected String field2; } class ColumnThreeAndNine…
user634545
  • 9,099
  • 5
  • 29
  • 40
1
vote
1 answer

How to append empty or null values without quote in uniVocity CsvWriter

Im trying to append row, using CSVWriter by uniVocity When i set settings.setQuoteAllFields(true); then all fields are quoted, this is logical, but can i set any settings NOT to apply quotes in empty or null fields? For example, when i call String…
1
vote
1 answer

Why getAnnotation(Parsed.class).field() returning String[]?(It should return String, as it is taking input as String)

I have following code. import com.univocity.parsers.annotations.Parsed; import org.apache.commons.lang3.reflect.FieldUtils; import java.lang.reflect.Field; public class MyClass { public static void main(String args[]) { try{ …
yajiv
  • 2,901
  • 2
  • 15
  • 25
1
vote
1 answer

Does Univocity parsing support java 8 datetime type conversion (LocalDateTime)?

@Parsed(field="ABC") @Format(formats="yyyy-MM-dd HH:mm:ss.SSSSSSSSS") private LocalDateTime abcDateTime; Is above supported in Univocity Parsing ? using 2.8.1 version
Rakesh
  • 235
  • 2
  • 10
1
vote
1 answer

Break CSV into multiple parts with Univocity

I have a CSV with multiple datasets in it. For ex, FIELD1, 10, FIELD2, 20, FIELD3, 30 // dataset1 begins here FIELD4, 40, FIELD5, 50 // line 2 of dataset1 SUBFIELD1_ROW1, 100, SUBFIELD2_ROW1, 200 // subsection of dataset1: line1 SUBFIELD1_ROW2, 300,…
s.r
  • 2,507
  • 3
  • 22
  • 32
1
vote
1 answer

Why univocity's CsvParser throwing error when use LocalDate as the datatype for POJO and How to reslove it?

I am using Univocity's CSVParser to read csv file. My POJO look something like this. import java.time.LocalDate; import com.univocity.parsers.annotations.NullString; import com.univocity.parsers.annotations.Parsed; import lombok.Builder; import…
yajiv
  • 2,901
  • 2
  • 15
  • 25
1
vote
1 answer

Univocity parser using routines ignores the LongCoversion using defaultNullRead attribute?

I have below field configuration: @Parsed(field="TEST_ID", defaultNullRead="000000") private Long testId now when the input file (csv parsing) contains value as NULL, it is not converting to default long value of 0, rather throws LongConversion…
Rakesh
  • 235
  • 2
  • 10
1
vote
1 answer

univocity - How to parse string from selected char

I have next .csv file: tt0102057, 6, 2010-06-19, Hook tt0102059, 7 ,2013-06-23, Hot Shots! tt0102070, 5, 2010-02-10, Hudson Hawk I need to parse value from 1st column to the int value, not String. So i need to skip first two symbols and take the…
Andrey
  • 433
  • 1
  • 5
  • 19
1
vote
1 answer

@Validate not skipping invalid rows when used with CsvRoutines in UniVocity parser

I am using Univocity parser version 2.7.3. I have a CSV file that has 1 Million records and might grow in future. I am reading only a few specific columns from the file and below are my requirements: DO NOT store the CSV contents into memory at…
1
vote
2 answers

Key value parser implementation with CSV parser in java

I am writing a program to parse key value based log like this: dstcountry="United States" date=2018-12-13 time=23:47:32 I am using Univocity parser to do that. Here is my code. CsvParserSettings parserSettings = new…
Harikrishnan
  • 3,664
  • 7
  • 48
  • 77
1
vote
0 answers

How to parse a CSV with JSON fields containing separator?

I have the following CSV file with a JSON field that may contains the separator: 2.0.0|2018-11-04 10:10:14,471|eventname|{"fieldA":"value with separator | inside","fieldB":"54321"}|123456|empty I tried to use the following code to get the whole…
Mike Dias
  • 195
  • 1
  • 11
1
vote
0 answers

Can't parse Date with Univocity parser

Im using univocity for parsing csv file. But I cant parse date in String format to java.util.Date. It seems like the @Format(formats ="YYYY-MM-DD") annotation is not working. Im trying parse line…
Michael
  • 169
  • 2
  • 2
  • 16
1
vote
1 answer

Univocity CSV parser multiple beans with multiple rows in single CSV

Given the following classes public class Inventory { private InventoryHeader header; private List lines; } public class InventoryHeader { private String date; private boolean isCurrent; } public class InventoryLine…
user2827048
  • 539
  • 6
  • 18
1
vote
2 answers

Write Object with Collection to CSV using UniVocity

Given two Classes public class Inventory { private List lines; } and public class InventoryLine { private String itemName; private int quantity; private String description; } I would like to print the following CSV…
user2827048
  • 539
  • 6
  • 18
1
vote
1 answer

Issue while using default null conversion in univocity

I am using univocity parser for parsing csv files. @NullString(nulls = { "", " " }) @Parsed( field = "referenceNumber1", defaultNullRead = "NULL") private String referenceNumber1; @NullString(nulls = { "", " " }) @Parsed( …
Harsh
  • 75
  • 5