Author of the lib here. This is not a parser bug. The problem you have here is that you are NOT parsing a CSV file.
When the parser sees: dstcountry="United
, followed by a space (which is your delimiter), it will consider that as a value.
The quote setting only applies to fields that start with a quote character. As your input is not "dstcountry=""United States"""
, the parser won't be able to process this as you want. There is no CSV parser that can do that for you.
Again, you are not processing a CSV. The only thing you could do here is to use 2 parser instances: one to break down the row around the =
and another one to break down values separated by
in the result of the first parser. For example:
CsvParserSettings parserSettings = new CsvParserSettings();
//break down the rows around the `=` character
parserSettings.getFormat().setDelimiter('=');
CsvParser keyValueParser = new CsvParser(parserSettings);
String line = "dstcountry=\"United States\" date=2018-12-13 time=23:47:32";
String[] keyPairs = keyValueParser.parseLine(line);
//break down each value around the whitespace.
parserSettings.getFormat().setDelimiter(' ');
CsvParser valueParser = new CsvParser(parserSettings);
//add all values to a list
List<String> row = new ArrayList<String>();
for(String value : keyPairs){
//if a value has a whitespace, break it down using the the other parser instance
String[] values = valueParser.parseLine(value);
Collections.addAll(row, values);
}
//here is your result
System.out.println(row);
This will print out:
[dstcountry, United States, date, 2018-12-13, time, 23:47:32]
You now have the key values. The following code will print this out as you want:
for (int i = 0; i < row.size(); i += 2) {
System.out.println(row.get(i) + " = " + row.get(i + 1));
}
Output:
dstcountry = United States
date = 2018-12-13
time = 23:47:32
Hope this helps and thank you for using our parsers!