Skip to content

Commit

Permalink
fix: Throw an error if CSV is malformed (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Romuald Rousseau <[email protected]>
  • Loading branch information
RomualdRousseau and Romuald Rousseau authored Nov 13, 2024
1 parent cf63ee0 commit c40223d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ private DataFrame processRows(final BufferedReader reader, final DataFrameWriter

private String[] parseOneRow(final String data, final String separator) {
final var result = new ArrayList<String>();
var acc = "";
var state = 0;
var acc = "";

final char[] tmp = data.toCharArray();
for (int i = 0; i < tmp.length; i++) {
Expand Down Expand Up @@ -173,6 +173,10 @@ private String[] parseOneRow(final String data, final String separator) {
}
}

if (state == 1) {
throw new RuntimeException(String.format("Malformed CSV: %s", data));
}

if (!acc.trim().equals("")) {
result.add(acc);
}
Expand Down

0 comments on commit c40223d

Please sign in to comment.