Changeset 28794 for main/trunk
- Timestamp:
- 2014-01-15T14:35:55+13:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-sites-dev/von-sparql/collect/nz-natlib-cat/pre-import/marcXML_Split/src/split.java
r28734 r28794 13 13 //Default values for arguments 14 14 int NRecords = 250; 15 String OutputPath = "./out/ ";15 String OutputPath = "./out/nz_out"; 16 16 String InputPath = "./NZDataFull.xml"; 17 //String InputPath = "./NZ-small-macron-test.xml"; 17 18 18 19 //Incorrect number of arguments supplied 19 if(args.length!= 4)20 if(args.length!=2) 20 21 { 21 System.err.println("USAGE: java split [-n records_per_file] [-ooutput_path]");22 System.err.println("USAGE: ./RUN [records_per_file] [output_path]"); 22 23 return; 23 24 } 24 //read arguments 25 for(int i=0; i < args.length; i+=2) 25 26 try{ 27 NRecords = Integer.parseInt(args[0]); 28 OutputPath = args[1]; 29 } 30 catch(Exception e) 26 31 { 27 if(args[i].equals("-n")) 28 NRecords = Integer.parseInt(args[i+1]); 29 else if(args[i].equals("-o")) 30 OutputPath = args[i+1]; 31 } 32 32 System.err.println("Invalid Arguments"); 33 System.err.println("USAGE: ./RUN [records_per_file] [output_path]"); 34 return; 35 } 36 33 37 InputStream in; 34 38 try{ … … 44 48 File f; 45 49 int RecordCount = 0; 50 int ParseErrorCount = 0; 46 51 47 52 while(reader.hasNext()) 48 { 53 { 49 54 f = new File(TempFilename); 50 MarcWriter writer = new MarcXmlWriter(new FileOutputStream(f), true);55 MarcWriter writer = new MarcXmlWriter(new FileOutputStream(f),"UTF8",true); 51 56 Record record; 52 57 … … 54 59 for(int i=0; (i<NRecords && reader.hasNext()); i++) 55 60 { 56 record = reader.next(); 57 writer.write(record); 58 RecordCount++; 61 try { 62 record = reader.next(); 63 } 64 catch (Exception e) { 65 System.err.println("Warning: Failed to parse record number: " + RecordCount); 66 ParseErrorCount++; 67 continue; 68 } 69 writer.write(record); 70 RecordCount++; 59 71 } 60 72 writer.close();
Note:
See TracChangeset
for help on using the changeset viewer.