アットウィキロゴ

再処理88

package datax;
 
import java.io.File;
import java.io.*;
import tool.*;   
 
public class pro {
 
    String[] subdata=new String[200000];
 
        int fastline,lastline;
        int indexline,creditline,prefline,subline;
        int creditx,credity;
     int[] year=new int[50000];
    int[] month=new int[50000];
      String[] dic=new String[50000];
      String[] pref=new String[500];
        String[] data=new String[50000];
      String date;
  int maxy,maxx,datanumber;
 int dicnumber;
 int number;
 
    public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
       dic sub=new dic();
       sub.makedata();
       dic=sub.dic;
       dicnumber=sub.dicnumber;
       pref=sub.pref;
 
 
       int tr,s,sx;
       int n=0;
 
       for(tr=1;tr<13;tr++){
 
        readx("gdata/"+tr+".txt");
 
        for(s=1;s<datanumber+1;s++){
        catchword sub2=new catchword();
        String str=sub2.makedata(data[s],"credit");
        String str1=sub2.makedata(data[s],"pref");
        String y=sub2.makedata(data[s],"year");
        String v=sub2.makedata(data[s],"value");
        String c1="";
 
for(sx=1;sx<dicnumber+1;sx++){    
if(str.equals(dic[sx]))c1="c"+sx;
}
 
 
String p1=""; 
for(sx=1;sx<48;sx++){    
if(str1.equals(pref[sx]))p1="p"+sx;
}
 
n=n+1;
subdata[n]=y+","+c1+","+p1+","+str+","+str1+","+v;
System.out.println(subdata[n]); 
 
 
        }
 
 
       }
 
datanumber=n;
 
        writexml("r.csv");   
 
    }
 
void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<datanumber+1;s++){  
pw.println(subdata[s]);
}
 
 
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;
 
} 
 
 
 
    }
 
 
 
 
 
 
 
package datax;
 
 
import java.io.File;
import java.io.*;
import tool.*;   
 
public class dic {
 
    String[][] mat=new String[500][2000];
 
        int fastline,lastline;
        int indexline,creditline,prefline,subline;
        int creditx,credity;
     int[] year=new int[50000];
    int[] month=new int[50000];
      String[] dic=new String[50000];
      String[] pref=new String[500];
        String[] data=new String[50000];
      String date;
  int maxy,maxx,datanumber;
 
 
 
 
 
 
    int tr,s,dicnumber=0;
    int sx,number=0;
 
 
    void makedata(){
 
        File f=new File("gdata");
        String[] fx=f.list();
 
    maxy=100;
    maxx=500;
 
int trs=0;
 
 
    for(tr=0;tr<fx.length;tr++){
 
        readx("gdata/"+fx[tr]);
 
        for(s=1;s<datanumber+1;s++){
        catchword sub=new catchword();
         String str=sub.makedata(data[s],"credit");
        String str1=sub.makedata(data[s],"pref");
         int h=0;
         for(sx=1;sx<dicnumber+1;sx++){    
if(str.equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=str;
 
 
h=0;
         for(sx=1;sx<number+1;sx++){    
if(str1.equals(pref[sx]))h=100;
}
if(h<50)number=number+1;
if(h<50)pref[number]=str1;
 
 
        }
 
 
 
 
 
 
    }
 
 
 
for(sx=1;sx<dicnumber+1;sx++){    
System.out.println("c"+sx+","+dic[sx]);
}
 
 
    System.out.println(dicnumber);
    System.out.println(number);
 
    }
 
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年02月20日 13:37