source: other-projects/is-sheet-music-encore/trunk/java-gen-corpus/TabProcTextGen.java@ 33031

Last change on this file since 33031 was 33031, checked in by cpb16, 5 years ago

Completed numpages checking. Generated makefiles and scripts to streamline process. Need to now fix 'no such file or directory error from the RUN-META.sh file'.

File size: 1.6 KB
Line 
1//NAME:Caleb Bird
2//ID: 1289680
3//??References??
4
5import java.io.BufferedReader;
6import java.io.FileReader;
7import java.io.FileWriter;
8
9public class TabProcTextGen {
10 public static void main(String[] args) {
11 try{
12
13
14 if (args.length != 3) {
15 System.out.println("Usage: TabProcTextGen <inputFilename> <outputFilename> <inputType>");
16 }
17 else {
18 String inputFilename = args[0];
19 String outputFilename = args[1];
20 String inputType = args[2];
21
22
23 System.out.println("Processing: " + inputFilename);
24
25 FileReader fileReader = new FileReader(inputFilename);
26 BufferedReader buf = new BufferedReader(fileReader);
27 //FileWriter fw = new FileWriter("HathiDocIDList.txt");
28 FileWriter fw = new FileWriter(outputFilename);
29 String line = null;
30 String[] item;
31
32 //Splits into each record, since readLine splits by "\n"
33 int line_num = 0;
34
35 while ((line = buf.readLine()) != null) {
36 line_num++;
37 if (line_num%100000 == 0) {
38 System.out.print(".");
39 System.out.flush();
40 }
41
42 //Splits by tab, leaves "" for every blank entry
43 item = line.split("\t", -1);
44 //Check items to be equal
45 if( item[1].equals("allow") &&
46 item[2].equals("pd") &&
47 item[19].equals(inputType) &&
48 (item[24].equals("open")||item[24].equals("page"))){
49 //Write item to file
50 fw.write(item[0] + "\n");
51 }
52 }
53 buf.close();
54 fw.close();
55 }
56 }catch(Exception e){
57 e.printStackTrace();
58 }
59 }
60}
61
62//REFERNECES
63//https://www.javatpoint.com/java-filewriter-class
64//https://docs.oracle.com/javase/8/docs/api/index.html?java/io/FileWriter.html
Note: See TracBrowser for help on using the repository browser.