Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CSV read failure involving blank lines in RFC4180 mode. #2434

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/include/souffle/io/ReadStreamCSV.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ class ReadStreamCSV : public ReadStream {
pos = 0;
end = line.length();
}
if (pos == end) {
// this means we've got a blank line and we need to read
// more
continue;
}

char c = line[pos++];
if (c == '"' && (pos < end) && line[pos] == '"') {
// two double-quote => one double-quote
Expand Down
2 changes: 2 additions & 0 deletions tests/semantic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ positive_test(load8)
positive_test(load9)
negative_test(load10)
positive_test(load11)
positive_test(load12)
positive_test(load13)
positive_test(load_adt)
positive_test(load_adt2)
positive_test(load_adt3)
Expand Down
2 changes: 1 addition & 1 deletion tests/semantic/load11/A.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"foo
bar", nothing , "one
bar","nothing","one
two"
2 changes: 1 addition & 1 deletion tests/semantic/load11/facts/A.facts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"foo
bar", nothing , "one
bar",nothing,"one
two"
6 changes: 3 additions & 3 deletions tests/semantic/load11/load11.dl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.decl A(x:symbol)
.input A()
.output A()
.decl A(x:symbol,y:symbol,z:symbol)
.input A(rfc4180=true)
.output A(rfc4180=true)

4 changes: 4 additions & 0 deletions tests/semantic/load12/A.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"FOO","Line1

Line3.
"
4 changes: 4 additions & 0 deletions tests/semantic/load12/facts/A.facts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FOO,"Line1

Line3.
"
4 changes: 4 additions & 0 deletions tests/semantic/load12/load12.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.decl A(x:symbol, y:symbol)
.input A(rfc4180=true)
.output A(rfc4180=true)

Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/semantic/load13/A.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo"bar"
1 change: 1 addition & 0 deletions tests/semantic/load13/facts/A.facts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"foo""bar"""
4 changes: 4 additions & 0 deletions tests/semantic/load13/load13.dl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.decl A(x:symbol)
.input A(rfc4180=true)
.output A()

Empty file.
Empty file.
Loading