List of usage examples for org.apache.commons.csv CSVParser CSVParser
public CSVParser(final Reader reader, final CSVFormat format) throws IOException
If you do not read all records from the given reader , you should call #close() on the parser, unless you close the reader .
From source file:org.easybatch.extensions.apache.common.csv.ApacheCommonCsvSupportIntegrationTest.java
@Test public void testAllComponentsTogether() throws Exception { CSVFormat csvFormat = CSVFormat.DEFAULT.withHeader("id", "user", "message"); CSVParser parser = new CSVParser(new FileReader(this.getClass().getResource("/tweets.csv").getFile()), csvFormat);//from w w w. ja v a 2 s . c o m aNewJob().reader(new ApacheCommonCsvRecordReader(parser)) .mapper(new ApacheCommonCsvRecordMapper(Tweet.class)) .marshaller(new ApacheCommonCsvRecordMarshaller(Tweet.class, new String[] { "id", "user", "message" }, ';', '\'')) .writer(new StandardOutputRecordWriter()).call(); assertThat(systemOut.getLog()).isEqualTo("'1';'foo';'hello'" + LINE_SEPARATOR + "'2';'bar';'hey'" + LINE_SEPARATOR + "'3';'baz';'hi'" + LINE_SEPARATOR); }
From source file:org.etudes.mneme.tool.UploadCsv.java
/** * Parse the contents into CSV records./*from w w w . ja va2s . co m*/ */ protected void parse() { try { Reader in = new StringReader(this.contents); CSVParser parser = new CSVParser(in, CSVFormat.RFC4180); this.records = parser.getRecords(); parser.close(); } catch (IOException e) { } finally { } }
From source file:org.failearly.dataz.internal.template.generator.csv.CsvGeneratorImpl.java
@Override protected void doInit() { super.doInit(); try {/* w ww . j a va2 s. c om*/ final CSVFormat format = new CsvFormatResolver(csvProperties()).resolve().getCsvFormat(); final CSVParser parser = new CSVParser(loadResourceAsReader(getFileAttribute()), format); this.records = toCsvRecord(parser.getRecords()); } catch (IOException ex) { throw new DataSetException("Can't load resource", ex); } }
From source file:org.gephi.io.importer.plugin.file.spreadsheet.SpreadsheetUtils.java
public static CSVParser configureCSVParser(File file, Character fieldSeparator, Charset charset, boolean withFirstRecordAsHeader) throws IOException { if (fieldSeparator == null) { fieldSeparator = ','; }/*w w w .jav a2 s . co m*/ CSVFormat csvFormat = CSVFormat.DEFAULT.withDelimiter(fieldSeparator).withEscape('\\') .withIgnoreEmptyLines(true).withNullString("").withIgnoreSurroundingSpaces(true).withTrim(true); if (withFirstRecordAsHeader) { csvFormat = csvFormat.withFirstRecordAsHeader().withAllowMissingColumnNames(false) .withIgnoreHeaderCase(false); } else { csvFormat = csvFormat.withHeader((String[]) null).withSkipHeaderRecord(false); } boolean hasBOM = false; try (FileInputStream is = new FileInputStream(file)) { CharsetToolkit charsetToolkit = new CharsetToolkit(is); hasBOM = charsetToolkit.hasUTF8Bom() || charsetToolkit.hasUTF16BEBom() || charsetToolkit.hasUTF16LEBom(); } catch (IOException e) { //NOOP } FileInputStream fileInputStream = new FileInputStream(file); InputStreamReader is = new InputStreamReader(fileInputStream, charset); if (hasBOM) { try { is.read(); } catch (IOException e) { // should never happen, as a file with no content // but with a BOM has at least one char } } return new CSVParser(is, csvFormat); }
From source file:org.hoteia.qalingo.translation.LoaderTranslationUtil.java
public static final void buildMessagesProperties(String currentPath, String project, String filePath, List<String> activedLanguages, String defaultLanguage, String inputEncoding, String outputEncoding) { try {/*from ww w .j av a 2s.com*/ String newPath = currentPath + project + LoaderTranslation.PROPERTIES_PATH; File folderProject = new File(newPath); if (!folderProject.exists()) { folderProject.mkdirs(); } InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(filePath)), inputEncoding); LOG.info("File CSV encoding: " + inputEncoding); LOG.info("File properties encoding: " + outputEncoding); CSVFormat csvFormat = CSVFormat.DEFAULT; CSVParser readerCSV = new CSVParser(reader, csvFormat); List<CSVRecord> records = null; try { records = readerCSV.getRecords(); } catch (Exception e) { LOG.error("Failed to load: " + filePath, e); } String prefixFileName = ""; CSVRecord firstLineRecord = records.get(0); String[] prefixFileNameTemp = firstLineRecord.get(0).split("## Filename :"); if (prefixFileNameTemp.length > 1) { prefixFileName = prefixFileNameTemp[1].trim(); } String prefixKey = ""; CSVRecord secondLineRecord = records.get(1); String[] prefixKeyTemp = secondLineRecord.get(0).split("## PrefixKey :"); if (prefixKeyTemp.length > 1) { prefixKey = prefixKeyTemp[1].trim(); } Map<String, Integer> availableLanguages = new HashMap<String, Integer>(); for (CSVRecord record : records) { String firstCell = record.get(0); if (firstCell.contains("Prefix") && record.size() > 1) { String secondCell = record.get(1); if (secondCell.contains("Key")) { for (int i = 2; i < record.size(); i++) { String languageCode = record.get(i); availableLanguages.put(languageCode, new Integer(i)); } break; } } } // BUILD DEFAULT FILE String fileFullPath = newPath + "/" + prefixFileName + ".properties"; Integer defaultLanguagePosition = availableLanguages.get(defaultLanguage); buildMessagesProperties(records, fileFullPath, prefixKey, defaultLanguage, defaultLanguagePosition, outputEncoding, true); for (Iterator<String> iterator = availableLanguages.keySet().iterator(); iterator.hasNext();) { String languageCode = (String) iterator.next(); if (activedLanguages.contains(languageCode)) { Integer languagePosition = availableLanguages.get(languageCode); String languegFileFullPath = newPath + "/" + prefixFileName + "_" + languageCode + ".properties"; buildMessagesProperties(records, languegFileFullPath, prefixKey, languageCode, languagePosition.intValue(), outputEncoding, false); } } LOG.info(newPath + "/" + prefixFileName + ".properties"); } catch (Exception e) { LOG.info("Exception", e); } }
From source file:org.italiangrid.storm.webdav.authz.vomap.MapfileVOMembershipSource.java
private CSVParser getParser() { try {//w w w . j av a2s .co m return new CSVParser(new FileReader(mapFile), CSVFormat.DEFAULT); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:org.languagetool.rules.spelling.morfologik.suggestions_ordering.SuggestionsOrdererTest.java
public static void main(String[] args) throws IOException { Map<String, JLanguageTool> ltMap = new HashMap<>(); Map<String, Rule> rules = new HashMap<>(); Map<String, SuggestionsOrderer> ordererMap = new HashMap<>(); final AtomicInteger numOriginalCorrect = new AtomicInteger(0), numReorderedCorrect = new AtomicInteger(0), numOtherCorrect = new AtomicInteger(0), numBothCorrect = new AtomicInteger(0), numTotalReorderings = new AtomicInteger(0), numMatches = new AtomicInteger(0); AtomicLong totalReorderingComputationTime = new AtomicLong(0), totalHunspellComputationTime = new AtomicLong(0); Runtime.getRuntime()/* w ww . j a v a 2 s .c o m*/ .addShutdownHook(new Thread(() -> System.out.printf( "%n**** Correct Suggestions ****%nBoth: %d / Original: %d / Reordered: %d / Other: %d%n" + "Average time per reordering: %fms / Average time in match(): %fms%n", numBothCorrect.intValue(), numOriginalCorrect.intValue(), numReorderedCorrect.intValue(), numOtherCorrect.intValue(), (double) totalReorderingComputationTime.get() / numTotalReorderings.get(), (double) totalHunspellComputationTime.get() / numMatches.get()))); SuggestionsOrdererConfig.setNgramsPath(args[1]); try (CSVParser parser = new CSVParser(new FileReader(args[0]), CSVFormat.DEFAULT.withFirstRecordAsHeader())) { for (CSVRecord record : parser) { String lang = record.get("language"); String covered = record.get("covered"); String replacement = record.get("replacement"); String sentenceStr = record.get("sentence"); if (lang.equals("auto") || !(lang.equals("en-US") || lang.equals("de-DE"))) { // TODO: debugging only continue; // TODO do language detection? } Language language = Languages.getLanguageForShortCode(lang); JLanguageTool lt = ltMap.computeIfAbsent(lang, langCode -> new JLanguageTool(language)); Rule spellerRule = rules.computeIfAbsent(lang, langCode -> lt.getAllRules().stream() .filter(Rule::isDictionaryBasedSpellingRule).findFirst().orElse(null)); if (spellerRule == null) { continue; } SuggestionsOrderer orderer = null; try { orderer = ordererMap.computeIfAbsent(lang, langCode -> new SuggestionsOrdererGSoC(language, null, spellerRule.getId())); } catch (RuntimeException ignored) { } if (orderer == null) { continue; } numMatches.incrementAndGet(); AnalyzedSentence sentence = lt.getAnalyzedSentence(sentenceStr); long startTime = System.currentTimeMillis(); RuleMatch[] matches = spellerRule.match(sentence); totalHunspellComputationTime.addAndGet(System.currentTimeMillis() - startTime); for (RuleMatch match : matches) { String matchedWord = sentence.getText().substring(match.getFromPos(), match.getToPos()); if (!matchedWord.equals(covered)) { //System.out.println("Other spelling error detected, ignoring: " + matchedWord + " / " + covered); continue; } List<String> original = match.getSuggestedReplacements(); SuggestionsOrdererConfig.setMLSuggestionsOrderingEnabled(true); numTotalReorderings.incrementAndGet(); startTime = System.currentTimeMillis(); List<String> reordered = orderer.orderSuggestionsUsingModel(original, matchedWord, sentence, match.getFromPos()); totalReorderingComputationTime.addAndGet(System.currentTimeMillis() - startTime); SuggestionsOrdererConfig.setMLSuggestionsOrderingEnabled(false); if (original.isEmpty() || reordered.isEmpty()) { continue; } String firstOriginal = original.get(0); String firstReordered = reordered.get(0); if (firstOriginal.equals(firstReordered)) { if (firstOriginal.equals(replacement)) { numBothCorrect.incrementAndGet(); } else { numOtherCorrect.incrementAndGet(); } //System.out.println("No change for match: " + matchedWord); } else { System.out.println("Ordering changed for match " + matchedWord + ", before: " + firstOriginal + ", after: " + firstReordered + ", choosen: " + replacement); if (firstOriginal.equals(replacement)) { numOriginalCorrect.incrementAndGet(); } else if (firstReordered.equals(replacement)) { numReorderedCorrect.incrementAndGet(); } else { numOtherCorrect.incrementAndGet(); } } } } } }
From source file:org.languagetool.rules.spelling.suggestions.SuggestionChangesTest.java
public void testChanges() throws IOException, InterruptedException { File configFile = new File(System.getProperty("config", "SuggestionChangesTestConfig.json")); ObjectMapper mapper = new ObjectMapper(new JsonFactory().enable(JsonParser.Feature.ALLOW_COMMENTS)); SuggestionChangesTestConfig config = mapper.readValue(configFile, SuggestionChangesTestConfig.class); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); String timestamp = dateFormat.format(new Date()); Path loggingFile = Paths.get(config.logDir, String.format("suggestionChangesExperiment_%s.log", timestamp)); Path datasetFile = Paths.get(config.logDir, String.format("suggestionChangesExperiment_%s.csv", timestamp)); BufferedWriter writer = Files.newBufferedWriter(loggingFile); CSVPrinter datasetWriter = new CSVPrinter(Files.newBufferedWriter(datasetFile), CSVFormat.DEFAULT.withEscape('\\')); List<String> datasetHeader = new ArrayList<>( Arrays.asList("sentence", "correction", "covered", "replacement", "dataset_id")); SuggestionsChanges.init(config, writer); writer.write("Evaluation configuration: \n"); String configContent = String.join("\n", Files.readAllLines(configFile.toPath())); writer.write(configContent);//from w w w. ja v a 2s. c o m writer.write("\nRunning experiments: \n"); int experimentId = 0; for (SuggestionChangesExperiment experiment : SuggestionsChanges.getInstance().getExperiments()) { experimentId++; writer.write(String.format("#%d: %s%n", experimentId, experiment)); datasetHeader.add(String.format("experiment_%d_suggestions", experimentId)); datasetHeader.add(String.format("experiment_%d_metadata", experimentId)); datasetHeader.add(String.format("experiment_%d_suggestions_metadata", experimentId)); } writer.newLine(); datasetWriter.printRecord(datasetHeader); BlockingQueue<SuggestionTestData> tasks = new LinkedBlockingQueue<>(1000); ConcurrentLinkedQueue<Pair<SuggestionTestResultData, String>> results = new ConcurrentLinkedQueue<>(); List<SuggestionTestThread> threads = new ArrayList<>(); for (int i = 0; i < Runtime.getRuntime().availableProcessors(); i++) { SuggestionTestThread worker = new SuggestionTestThread(tasks, results); worker.start(); threads.add(worker); } // Thread for writing results from worker threads into CSV Thread logger = new Thread(() -> { try { long messages = 0; //noinspection InfiniteLoopStatement while (true) { Pair<SuggestionTestResultData, String> message = results.poll(); if (message != null) { writer.write(message.getRight()); SuggestionTestResultData result = message.getLeft(); int datasetId = 1 + config.datasets.indexOf(result.getInput().getDataset()); if (result != null && result.getSuggestions() != null && !result.getSuggestions().isEmpty() && result.getSuggestions().stream() .noneMatch(m -> m.getSuggestedReplacements() == null || m.getSuggestedReplacements().isEmpty())) { List<Object> record = new ArrayList<>(Arrays.asList(result.getInput().getSentence(), result.getInput().getCorrection(), result.getInput().getCovered(), result.getInput().getReplacement(), datasetId)); for (RuleMatch match : result.getSuggestions()) { List<String> suggestions = match.getSuggestedReplacements(); record.add(mapper.writeValueAsString(suggestions)); // features extracted by SuggestionsOrdererFeatureExtractor record.add(mapper.writeValueAsString(match.getFeatures())); List<SortedMap<String, Float>> suggestionsMetadata = new ArrayList<>(); for (SuggestedReplacement replacement : match.getSuggestedReplacementObjects()) { suggestionsMetadata.add(replacement.getFeatures()); } record.add(mapper.writeValueAsString(suggestionsMetadata)); } datasetWriter.printRecord(record); } if (++messages % 1000 == 0) { writer.flush(); System.out.printf("Evaluated %d corrections.%n", messages); } } } } catch (IOException e) { throw new RuntimeException(e); } }); logger.setDaemon(true); logger.start(); // format straight from database dump String[] header = { "id", "sentence", "correction", "language", "rule_id", "suggestion_pos", "accept_language", "country", "region", "created_at", "updated_at", "covered", "replacement", "text_session_id", "client" }; int datasetId = 0; // read data, send to worker threads via queue for (SuggestionChangesDataset dataset : config.datasets) { writer.write(String.format("Evaluating dataset #%d: %s.%n", ++datasetId, dataset)); CSVFormat format = CSVFormat.DEFAULT; if (dataset.type.equals("dump")) { format = format.withEscape('\\').withNullString("\\N").withHeader(header); } else if (dataset.type.equals("artificial")) { format = format.withEscape('\\').withFirstRecordAsHeader(); } try (CSVParser parser = new CSVParser(new FileReader(dataset.path), format)) { for (CSVRecord record : parser) { String lang = record.get("language"); String rule = dataset.type.equals("dump") ? record.get("rule_id") : ""; String covered = record.get("covered"); String replacement = record.get("replacement"); String sentence = record.get("sentence"); String correction = record.isSet("correction") ? record.get("correction") : ""; String acceptLanguage = dataset.type.equals("dump") ? record.get("accept_language") : ""; if (sentence == null || sentence.trim().isEmpty()) { continue; } if (!config.language.equals(lang)) { continue; // TODO handle auto maybe? } if (dataset.type.equals("dump") && !config.rule.equals(rule)) { continue; } // correction column missing in export from doccano; workaround if (dataset.enforceCorrect && !record.isSet("correction")) { throw new IllegalStateException("enforceCorrect in dataset configuration enabled," + " but column 'correction' is not set for entry " + record); } if (dataset.type.equals("dump") && dataset.enforceAcceptLanguage) { if (acceptLanguage != null) { String[] entries = acceptLanguage.split(",", 2); if (entries.length == 2) { String userLanguage = entries[0]; // TODO: what to do with e.g. de-AT,de-DE;... if (!config.language.equals(userLanguage)) { continue; } } } } tasks.put(new SuggestionTestData(lang, sentence, covered, replacement, correction, dataset)); } } } for (Thread t : threads) { t.join(); } logger.join(10000L); logger.interrupt(); datasetWriter.close(); }
From source file:org.languagetool.rules.spelling.SuggestionsChangesTest.java
/*** * TODO: document/*from w w w .j a v a 2 s . c om*/ * @throws IOException */ @Test public void testChanges() throws IOException { String correctionsFileLocation = System.getProperty("correctionsFileLocation"); assertNotEquals("needs corrections data", null, correctionsFileLocation); String testMode = System.getProperty("suggestionsTestMode"); assertThat(testMode, is(anyOf(equalTo("A"), equalTo("B"), equalTo("AB")))); if (testMode.equals("A") || testMode.equals("B")) { String modeValue = testMode.equals("A") ? "0" : "1"; System.setProperty("SuggestionsChangesTestAlternativeEnabled", modeValue); } String languagesValue = System.getProperty("languages"); Set<Language> languages = new HashSet<>(); if (languagesValue == null) { // default -> all languages languages.addAll(Languages.get()); } else { for (String langCode : languagesValue.split(",")) { languages.add(Languages.getLanguageForShortCode(langCode)); } } Random sampler = new Random(0); final float SAMPLE_RATE = 1f; Map<String, JLanguageTool> ltMap = new HashMap<>(); Map<String, Rule> rules = new HashMap<>(); final AtomicInteger numOriginalCorrect = new AtomicInteger(0), numReorderedCorrect = new AtomicInteger(0), numOtherCorrect = new AtomicInteger(0), numBothCorrect = new AtomicInteger(0), numMatches = new AtomicInteger(0), numCorrectSuggestion = new AtomicInteger(0), numTotal = new AtomicInteger(0); Runtime.getRuntime().addShutdownHook(new Thread(() -> { if (testMode.equals("AB")) { System.out.printf( "%n**** Correct Suggestions ****%nBoth: %d / Original: %d / Reordered: %d / Other: %d%n", numBothCorrect.intValue(), numOriginalCorrect.intValue(), numReorderedCorrect.intValue(), numOtherCorrect.intValue()); int total = numOriginalCorrect.intValue() + numReorderedCorrect.intValue() + numOtherCorrect.intValue() + numBothCorrect.intValue(); float accuracyA = (float) (numBothCorrect.intValue() + numOriginalCorrect.intValue()) / total; float accuracyB = (float) (numBothCorrect.intValue() + numReorderedCorrect.intValue()) / total; System.out.printf("**** Accuracy ****%nA: %f / B: %f%n", accuracyA, accuracyB); } else { String name = testMode.equals("A") ? "Original" : "Alternative"; int correct = numCorrectSuggestion.intValue(); int total = numTotal.intValue(); float percentage = 100f * ((float) correct / total); System.out.printf("%n**** Correct Suggestions ****%n %s: %d / %d (%f%%)%n", name, correct, total, percentage); } })); try (CSVParser parser = new CSVParser(new FileReader(correctionsFileLocation), CSVFormat.DEFAULT.withFirstRecordAsHeader())) { for (CSVRecord record : parser) { if (sampler.nextFloat() > SAMPLE_RATE) { continue; } String lang = record.get("language"); String covered = record.get("covered"); String replacement = record.get("replacement"); //String sentenceStr = record.get("sentence"); if (lang.equals("auto")) { continue; // TODO do language detection? } Language language = Languages.getLanguageForShortCode(lang); if (!languages.contains(language)) { continue; } JLanguageTool lt = ltMap.computeIfAbsent(lang, langCode -> { try { JLanguageTool tool = new JLanguageTool(language); tool.activateLanguageModelRules(new File("ngrams/")); return tool; } catch (IOException e) { throw new RuntimeException(e); } }); Rule spellerRule = rules.computeIfAbsent(lang, langCode -> lt.getAllRules().stream() .filter(Rule::isDictionaryBasedSpellingRule).findFirst().orElse(null)); if (spellerRule == null) { continue; } numMatches.incrementAndGet(); //AnalyzedSentence sentence = lt.getAnalyzedSentence(sentenceStr); AnalyzedSentence sentence = lt.getAnalyzedSentence(covered); if (testMode.equals("AB")) { System.setProperty("SuggestionsChangesTestAlternativeEnabled", "0"); RuleMatch[] originalMatches = spellerRule.match(sentence); System.setProperty("SuggestionsChangesTestAlternativeEnabled", "1"); RuleMatch[] alternativeMatches = spellerRule.match(sentence); assertEquals(originalMatches.length, alternativeMatches.length); for (int i = 0; i < originalMatches.length; i++) { RuleMatch original = originalMatches[i]; RuleMatch alternative = alternativeMatches[i]; String matchedWord = sentence.getText().substring(original.getFromPos(), original.getToPos()); String matchedWord2 = sentence.getText().substring(alternative.getFromPos(), alternative.getToPos()); assertEquals(matchedWord, matchedWord2); if (!matchedWord.equals(covered)) { //System.out.println("Other spelling error detected, ignoring: " + matchedWord + " / " + covered); continue; } List<String> originalSuggestions = original.getSuggestedReplacements(); List<String> alternativeSuggestions = alternative.getSuggestedReplacements(); if (originalSuggestions.size() == 0 || alternativeSuggestions.size() == 0) { continue; } String firstOriginal = originalSuggestions.get(0); String firstAlternative = alternativeSuggestions.get(0); if (firstOriginal.equals(firstAlternative)) { if (firstOriginal.equals(replacement)) { numBothCorrect.incrementAndGet(); } else { numOtherCorrect.incrementAndGet(); } System.out.println("No change for match: " + matchedWord); } else { String correct; if (firstOriginal.equals(replacement)) { numOriginalCorrect.incrementAndGet(); correct = "A"; } else if (firstAlternative.equals(replacement)) { numReorderedCorrect.incrementAndGet(); correct = "B"; } else { numOtherCorrect.incrementAndGet(); correct = "other"; } System.out.printf( "Ordering changed for match %s, before: %s, after: %s, choosen: %s, correct: %s%n", matchedWord, firstOriginal, firstAlternative, replacement, correct); } } } else { RuleMatch[] matches = spellerRule.match(sentence); for (RuleMatch match : matches) { String matchedWord = sentence.getText().substring(match.getFromPos(), match.getToPos()); if (!matchedWord.equals(covered)) { //System.out.println("Other spelling error detected, ignoring: " + matchedWord + " / " + covered); continue; } List<String> suggestions = match.getSuggestedReplacements(); if (suggestions.size() == 0) { continue; } String first = suggestions.get(0); numTotal.incrementAndGet(); System.out.printf("Correction for %s: %s %s / chosen: %s -> position %d%n", covered, first, suggestions.subList(1, Math.min(suggestions.size(), 5)), replacement, suggestions.indexOf(replacement)); if (first.equals(replacement)) { numCorrectSuggestion.incrementAndGet(); } } } } } }
From source file:org.marketcetera.orderloader.OrderParser.java
/** * Parses rows out of the supplied file and uses the processors to * process them./*w w w .j av a2 s. c o m*/ * * @param inStream the input stream with csv input containing orders. * The stream is closed when this method returns. * * @throws IOException if there was an error opening the supplied file or * if the file had no orders to send. * @throws OrderParsingException if the file didn't have the * column headers specified correctly or if the file didn't have any orders. */ public void parseOrders(InputStream inStream) throws IOException, OrderParsingException { UnicodeInputStreamReader reader = null; try { reader = new UnicodeInputStreamReader(inStream, DecodingStrategy.SIG_REQ); String[][] rows = new CSVParser(reader, CSVStrategy.EXCEL_STRATEGY).getAllValues(); boolean isProcessorInit = false; if (rows != null) { for (String[] row : rows) { mNumLines++; //Ignore empty lines. if (row.length == 0 || row.length == 1 && row[0].trim().isEmpty()) { mNumBlankLines++; } else if (row[0].startsWith(COMMENT_MARKER)) { mNumComments++; } else { if (isProcessorInit) { getProcessor().processOrder(mNumLines, row); } else { getProcessor().initialize(row); isProcessorInit = true; } } } } if (getProcessor().getTotal() < 1) { throw new OrderParsingException(ERROR_NO_ORDERS); } } finally { if (reader != null) { reader.close(); } if (inStream != null) { inStream.close(); } } }