mattyb149 commented on code in PR #7952:
URL: https://github.com/apache/nifi/pull/7952#discussion_r1473639064


##########
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/csv/AbstractCSVRecordReader.java:
##########
@@ -158,4 +180,46 @@ protected String trim(String value) {
     public RecordSchema getSchema() {
         return schema;
     }
+
+    /**
+     * This method searches using the specified Reader character-by-character 
until the
+     * record separator is found.
+     * @param reader the Reader providing the input
+     * @param recordSeparator the String specifying the end of a record in the 
input
+     * @throws IOException if an error occurs during reading, including not 
finding the record separator in the input
+     */
+    protected void readNextRecord(Reader reader, String recordSeparator) 
throws IOException {
+        int indexIntoSeparator = 0;
+        int recordSeparatorLength = recordSeparator.length();
+        int code = reader.read();
+        while (code != -1) {
+            char nextChar = (char)code;
+            if (recordSeparator.charAt(indexIntoSeparator) == nextChar) {
+                if (++indexIntoSeparator == recordSeparatorLength) {
+                    // We have matched the separator, return the string built 
so far
+                    return;
+                }

Review Comment:
   Actually come to think of it, this capability is to skip lines aren't AREN'T 
valid CSV, otherwise you can use SampleRecord. Because we aren't assuming the 
skipped rows to be valid CSV, we should be able to just match on the newline 
character. I'll put in some code anyway but what are your thoughts?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to