/** * Read in list two columns, title then ISSN, strings separated by white space. * * <p>Use <tt>(String[]) FileInputreadStringList(fullFileName).toArray()</tt> to get array of * strings instead of an ArrayList. * * @param fullFileName name of file including directories * @param infoLevel 0 = normal, 2= debugging, -2 = silent * @return list of journals found. */ public TreeSet<Journal> readSimpleJournalData(String fullFileName, int infoLevel) { TextReader tr = ProcessScopusJournalLists.openFile(fullFileName); if (tr == null) return null; if (infoLevel > -2) System.out.println("Starting to read list of strings from " + fullFileName); ArrayList<String> words = new ArrayList(); TreeSet<Journal> journalList = new TreeSet(); String[] labelList = {JournalTitleLabel, this.ISSNLabel}; int rowNumber = 0; try { String[] column; // first find header row and identify columns needed String header; // column = line.split("\\t+"); // split at every tab int[] columnIndex = null; while (tr.eof() == false && columnIndex == null) { rowNumber++; header = tr.getln(); column = header.split("\\t+"); // split at every tab columnIndex = testLabelRow(column, labelList); } if (columnIndex == null) throw new RuntimeException("*** no header columns found in fullFileName"); if (infoLevel > -1) System.out.println("... header in row " + rowNumber); if (infoLevel > 0) for (int c = 0; c < columnIndex.length; c++) System.out.println(labelList[c] + " in column " + columnIndex[c]); // now process main data String line; String ISSN; String title; Journal journal; while (tr.eof() == false) { rowNumber++; line = tr.getln(); column = line.split("\\t+"); // split at every tab ISSN = (column.length > 1 ? column[columnIndex[1]] : Journal.SUNSET); title = (column.length > 0 ? column[columnIndex[0]] : Journal.SUNSET); journal = new Journal(title, ISSN); journalList.add(journal); if (infoLevel > 1) System.out.println(rowNumber + " j=" + title + ", n=" + ISSN); } if (infoLevel > -2) System.out.println( "Finished reading journals from file " + fullFileName + " found " + journalList.size() + " journals"); } // eo try catch (TextReader.Error e) { // Some problem reading the noNamedata from the input file. throw new RuntimeException( "*** Input Error: readJournalData failed after " + journalList.size() + " journals, row " + rowNumber + ", " + e.getMessage()); } finally { tr.close(); } return journalList; }