Commit 817162aa authored by Robert Butora's avatar Robert Butora
Browse files

removes tests for csv parsing unused survey-populate.csv

parent 8074b194
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -4,14 +4,13 @@
  <groupId>vlkb</groupId>
  <artifactId>vlkb-siav2</artifactId>
  <packaging>war</packaging>
  <version>1.6.5</version>
  <name>psearch Maven Webapp</name>
  <version>x.y.z</version>
  <name>SIAv2 webapp</name>
  <url>http://maven.apache.org</url>

  <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
          <!-- FIXME needs JAVA_HOME=/usr/java/jdk-17.0.4.1 (java17 manually installed and aletrnatives activated) -->
          <maven.compiler.source>7</maven.compiler.source>
          <maven.compiler.target>7</maven.compiler.target>
  </properties>
@@ -38,6 +37,7 @@
                  <artifactId>jackson-databind</artifactId>
                  <version>2.15.1</version>
          </dependency>

          <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
          <dependency>
                  <groupId>com.fasterxml.jackson.core</groupId>
@@ -89,13 +89,6 @@
                  <scope>provided</scope>
          </dependency>

          <dependency>
                  <groupId>com.opencsv</groupId>
                  <artifactId>opencsv</artifactId>
                  <version>5.7.1</version>
                  <scope>provided</scope>
          </dependency>

          <!-- vlkb-volib dependencies -->

          <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
@@ -114,6 +107,8 @@

  </dependencies>



  <build>
          <finalName>${project.artifactId}-${git.buildnumber}</finalName>
          <plugins>
+0 −52
Original line number Diff line number Diff line

import com.opencsv.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.List;
import java.util.ArrayList;
import java.io.Reader;

class CsvParser
{
   public static void main(String[] args) throws Exception
   {
      Path filePath = Paths.get(args[0]);

      CsvParser parser = new CsvParser();

      List<String[]> lines = parser.readLineByLine(filePath);

      for(String[] strArr : lines)
      {
         for(String str : strArr) System.out.print(str + " | ");
         System.out.println();
      }
   }

   public List<String[]> readLineByLine(Path filePath) throws Exception
   {
      CSVParser parser = new CSVParserBuilder()
         .withSeparator(',')
         .withIgnoreQuotations(true)
         .build();

      List<String[]> list = new ArrayList<>();
      try (Reader reader = Files.newBufferedReader(filePath))
      {
         try (CSVReader csvReader = new CSVReaderBuilder(reader)
               .withSkipLines(0)
               .withCSVParser(parser)
               .build();
               // CSVReader csvReader = new CSVReader(reader)
             )
         {
            String[] line;
            while ((line = csvReader.readNext()) != null) {
               list.add(line);
            }
         }
      }
      return list;
   }
}
+0 −8
Original line number Diff line number Diff line


build:
	javac -classpath /home/robi/.m2/repository/com/opencsv/opencsv/5.7.1/opencsv-5.7.1.jar CsvParser.java


run:
	java -classpath /home/robi/.m2/repository/com/opencsv/opencsv/5.7.1/opencsv-5.7.1.jar:.:/home/robi/.m2/repository/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar CsvParser /srv/vlkb/surveys/survey_populate.csv 
+0 −59
Original line number Diff line number Diff line
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>vlkb</groupId>
  <artifactId>csv-parser</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>csv matadata parser</name>
  <url>http://maven.apache.org</url>

  <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
          <!-- FIXME needs JAVA_HOME=/usr/java/jdk-17.0.4.1 (java17 manually installed and aletrnatives activated) -->
          <maven.compiler.source>17</maven.compiler.source>
          <maven.compiler.target>17</maven.compiler.target>
  </properties>


  <dependencies>

          <dependency>
                  <groupId>com.opencsv</groupId>
                  <artifactId>opencsv</artifactId>
                  <version>5.7.1</version>
                  <scope>provided</scope>
          </dependency>


          <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>3.8.1</version>
                  <scope>test</scope>
          </dependency>

  </dependencies>

  <build>
          <finalName>csv-parser</finalName>
          <plugins>
                  <plugin>
                          <!-- Build an executable JAR -->
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-jar-plugin</artifactId>
                          <version>3.1.0</version>
                          <configuration>
                                  <archive>
                                          <manifest>
                                                  <addClasspath>true</addClasspath>
                                                  <classpathPrefix>lib/</classpathPrefix>
                                                  <mainClass>CsvParser</mainClass>
                                          </manifest>
                                  </archive>
                          </configuration>
                  </plugin>
  </plugins>  </build>

</project>