private static void parseFile()

in core/src/main/java/org/apache/sdap/mudrod/ssearch/ranking/DataGenerator.java [90:136]


  private static void parseFile() {
    String[][] dataArr = null;
    try {
      String sourceDir = mySourceDir;

      if (isMultFiles) // Case where multiple files have to be processed
      {
        // Iterate over files in directory 
        File directory = new File(sourceDir);
        File[] directoryListing = directory.listFiles();

        if (directoryListing != null) {
          for (File child : directoryListing) {
            try (CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(child), StandardCharsets.UTF_8))) {
              List<String[]> list = csvReader.readAll();
              // Store into 2D array by transforming array list to normal array
              dataArr = new String[list.size()][];
              dataArr = list.toArray(dataArr);
              calculateVec(dataArr);
            }
          }
          if (dataArr == null) {
            throw new RuntimeException("Specified CSV file content is empty to create header data!");
          }
          storeHead(dataArr); // Store the header
        }
      } else // Process only one file
      {
        File file = new File(sourceDir);

        if (file != null) {
          try (CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
            List<String[]> list = csvReader.readAll();

            // Store into 2D array by transforming array list to normal array
            dataArr = new String[list.size()][];
            dataArr = list.toArray(dataArr);

            storeHead(dataArr); // Store the header
            calculateVec(dataArr);
          }
        }
      }
    } catch (IOException e) {
      LOG.error("User specified CSV file parse failed : ", e);
    }
  }