アットウィキロゴ

再処理さいしょt@

package book;
 
import java.io.File;
import java.io.*;
 
public class pro {
 
    int number,dicnumber;
    String[] data=new String[6000];
    int s,datanumber;
    String[] code=new String[6000];
  String[] credit=new String[6000];
     String[] year=new String[6000];
  String[] v=new String[6000];
  String[] pref=new String[6000];
 
   String[] subdata=new String[600000];
 
    public static void main(String[] args) {
        pro te=new pro();
    }
    pro(){
 
 
           int de;
        int sx=0;
        for(de=2007;de<2018;de++){
        String a="gdata/"+de;
 
        File f=new File(a);
        String[] ff=f.list();
 
        int tr;
 
        for(tr=0;tr<ff.length;tr++){
 
            readx("gdata/"+de+"/"+ff[tr]);
 
            for(s=1;s<datanumber+1;s++){
            int p1=data[s].indexOf("<code>");
            int p2=data[s].indexOf("</code>");
            String str=data[s].substring(p1,p2);
            code[s]=str.replace("<code>","");
            p1=data[s].indexOf("<credit>");
            p2=data[s].indexOf("</credit>");
            str=data[s].substring(p1,p2);
            credit[s]=str.replace("<credit>","");
 
            p1=data[s].indexOf("<year>");
            p2=data[s].indexOf("</year>");
            str=data[s].substring(p1,p2);
            year[s]=str.replace("<year>","");
 
            p1=data[s].indexOf("<value>");
            p2=data[s].indexOf("</value>");
            str=data[s].substring(p1,p2);
            v[s]=str.replace("<value>","");
 
            p1=data[s].indexOf("<pref>");
            p2=data[s].indexOf("</pref>");
            str=data[s].substring(p1,p2);
            pref[s]=str.replace("<pref>","");
            sx=sx+1;
            subdata[sx]=""+de+","+year[s]+","+pref[s]+","+code[s]+","+credit[s]+","+v[s];  
 
            }
 
 
 
 
 
        }}
 
        System.out.println(sx);
 
        datanumber=sx;
 
        writexml("data.txt");
 
 
    }
 
    void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
 
 
pw.println("book,year,city,code,credit,v");
for(sx=1;sx<datanumber+1;sx++){
pw.println(subdata[sx]);   
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
void readx(String file){
 
String str;
BufferedReader br;  
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));  
while((str = br.readLine()) != null) {  
s=s+1;
data[s]=str;  
}
br.close();
} catch (IOException e) {System.out.println(e);}  
 
datanumber=s;
 
} 
 
 
}
 
最終更新:2017年03月13日 17:27