You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: CSVParser.getData returns String and not Array #21
However, even though I fix that bug and apply the parameter, the empty strings are not ignored and the CSV records with empty strings in them are still processed and triple is produced.
Oh yes, ignoreEmptyStrings not working with CSV is a bug.
Fixed with 95f863f & v1.10.2
However, even though I fix that bug and apply the parameter, the empty strings are not ignored and the CSV records with empty strings in them are still processed and triple is produced.
Could you maybe provide a sample CSV, I tried one of my own with empty fields and it worked just fine.
The RDF output looks as expected to me, what did you want the output to look like?
Did you want the RDF to not contains b3 - b5 because they do not contain the Tracker Name field? I'm afraid that is not so easy. With JSON or XML it would have been a matter of adding a filter to the iterator (e.g. with xpath /elements["Tracker Name"] or jsonpath $.*[?(@["Tracker Name"])]). But with CSV I'm afraid that is not possible, as CSV by default will iterate over all lines of the document.
As for the ignoreEmptyStrings feature, it's not documented very well, but what it does is ignore values in the input that are empty strings (or only whitespace) - as in, empty strings are treated the same way as if the value was not present.
E.g. with ignoreEmptyStrings:true the following are equal:
{
"foo": "",
"bar": "baz"
}
{
"bar": "baz"
}
while with ignoreEmptyStrings:false (the default) they are not (using foo in the mapping will result with an empty string literal in the RDF)
With CSV it makes less sense than with JSON/XML: does the CSV line: ,,, mean 4 empty strings or 4 undefined values. So far the behavior was to treat them as undefined values, and thus the ignoreEmptyStrings does not have any impact on CSV mappings (besides also ignoring extra whitespace " "," "," ").
It could make sense to actually treat ,,, as empty strings and so with ignoreEmptyStrings:false you'd get empty strings in the RDF. Or was this what you actually wanted? To get empty string literals in the RDF?
Did you want the RDF to not contains b3 - b5 because they do not contain the Tracker Name field?
Yes, exactly. Thank you for the pointers. I understand why it is not possible for CSV.
Thank you for better explaining ignoreEmptyStrings, it is much clearer now. And you also answered how it operates on CSV data - that's appreciated, in my understanding undefined/empty values in CSV are treated as undefined so they do not appear in the output even though a mapping is declared and regardless of ignoreEmptyStrings
I appreciate your time and the prompt and clear responses!
Activity
ThibaultGerrier commentedon Jul 19, 2021
Oh yes,
ignoreEmptyStringsnot working with CSV is a bug.Fixed with 95f863f & v1.10.2
Could you maybe provide a sample CSV, I tried one of my own with empty fields and it worked just fine.
valentinoli commentedon Jul 19, 2021
Great! Thank you
Here is the CSV:
And here is the YARRRML:
which I parsed into the following RML using
yarrrml-parserThen I used RocketRML to produce the following RDF with
ignoreEmptyStrings: trueThe empty nodes _:b3, _:b4, _:b5 correspond to lines with an empty string in the
Tracker NamefieldThibaultGerrier commentedon Jul 19, 2021
The RDF output looks as expected to me, what did you want the output to look like?
Did you want the RDF to not contains b3 - b5 because they do not contain the
Tracker Namefield? I'm afraid that is not so easy. With JSON or XML it would have been a matter of adding a filter to the iterator (e.g. with xpath/elements["Tracker Name"]or jsonpath$.*[?(@["Tracker Name"])]). But with CSV I'm afraid that is not possible, as CSV by default will iterate over all lines of the document.As for the
ignoreEmptyStringsfeature, it's not documented very well, but what it does is ignore values in the input that are empty strings (or only whitespace) - as in, empty strings are treated the same way as if the value was not present.E.g. with
ignoreEmptyStrings:truethe following are equal:{ "foo": "", "bar": "baz" }{ "bar": "baz" }while with
ignoreEmptyStrings:false(the default) they are not (using foo in the mapping will result with an empty string literal in the RDF)With CSV it makes less sense than with JSON/XML: does the CSV line:
,,,mean 4 empty strings or 4 undefined values. So far the behavior was to treat them as undefined values, and thus theignoreEmptyStringsdoes not have any impact on CSV mappings (besides also ignoring extra whitespace" "," "," ").It could make sense to actually treat
,,,as empty strings and so withignoreEmptyStrings:falseyou'd get empty strings in the RDF. Or was this what you actually wanted? To get empty string literals in the RDF?valentinoli commentedon Jul 19, 2021
Yes, exactly. Thank you for the pointers. I understand why it is not possible for CSV.
Thank you for better explaining
ignoreEmptyStrings, it is much clearer now. And you also answered how it operates on CSV data - that's appreciated, in my understanding undefined/empty values in CSV are treated as undefined so they do not appear in the output even though a mapping is declared and regardless ofignoreEmptyStringsI appreciate your time and the prompt and clear responses!