bossenti commented on code in PR #1290:
URL: https://github.com/apache/streampipes/pull/1290#discussion_r1208482981


##########
streampipes-extensions-management/src/main/java/org/apache/streampipes/extensions/management/connect/adapter/parser/CsvParser.java:
##########
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.extensions.management.connect.adapter.parser;
+
+
+import org.apache.streampipes.commons.exceptions.connect.ParseException;
+import org.apache.streampipes.extensions.api.connect.IParser;
+import org.apache.streampipes.extensions.api.connect.IParserEventHandler;
+import 
org.apache.streampipes.extensions.management.connect.adapter.util.DatatypeUtils;
+import org.apache.streampipes.model.Tuple2;
+import org.apache.streampipes.model.connect.grounding.ParserDescription;
+import org.apache.streampipes.model.connect.guess.GuessSchema;
+import org.apache.streampipes.model.staticproperty.Option;
+import org.apache.streampipes.model.staticproperty.StaticProperty;
+import org.apache.streampipes.sdk.builder.adapter.ParserDescriptionBuilder;
+import org.apache.streampipes.sdk.extractor.StaticPropertyExtractor;
+import org.apache.streampipes.sdk.helpers.Labels;
+
+import com.opencsv.CSVParser;
+import com.opencsv.CSVParserBuilder;
+import com.opencsv.CSVReader;
+import com.opencsv.CSVReaderBuilder;
+import com.opencsv.exceptions.CsvValidationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.IntStream;
+
+public class CsvParser implements IParser {
+
+  private static final Logger LOG = LoggerFactory.getLogger(CsvParser.class);
+
+  public static final String ID = 
"org.apache.streampipes.extensions.management.connect.adapter.parser.csv";
+  public static final String LABEL = "CSV";
+
+  public static final String DELIMITER = "delimiter";
+  public static final String HEADER = "header";
+
+  public static final String DESCRIPTION = "Can be used to read CSV";
+
+  private final ParserUtils parserUtils;
+
+  private boolean header;
+  private char delimiter;
+
+  public CsvParser() {
+    parserUtils = new ParserUtils();
+  }
+
+  public CsvParser(boolean header, char delimiter) {
+    this();
+    this.header = header;
+    this.delimiter = delimiter;
+  }
+
+  @Override
+  public IParser fromDescription(List<StaticProperty> config) {
+    StaticPropertyExtractor extractor = StaticPropertyExtractor.from(config);
+
+    char delimiter = extractor.singleValueParameter(DELIMITER, 
String.class).charAt(0);
+
+    boolean header = extractor.selectedMultiValues(HEADER, 
String.class).stream()
+        .anyMatch("Header"::equals);
+
+    return new CsvParser(header, delimiter);
+  }
+
+
+  @Override
+  public ParserDescription declareDescription() {
+    return ParserDescriptionBuilder.create(ID, LABEL, DESCRIPTION)
+        .requiredTextParameter(Labels.from(DELIMITER, "Delimiter",

Review Comment:
   Alright, https://github.com/apache/streampipes/issues/251 needs to be done 
first here, right?
   Then let's handle this within 251 and try to integrate 251 within the 0.93.0 
release



-- 
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