アットウィキロゴ

piebb

package delta;
 
import tool.*;
 
public class pro {
 
int s,datanumber;
String[] data=new String[50000];
 
 
 
      String[] v=new String[5000];
      String[] bus=new String[5000];
      String[] credit=new String[5000];
       String[] year=new String[5000];
  String[] month=new String[5000];
    String[] work=new String[5000];
    String[] size=new String[5000];
 
      String[] code_size=new String[50000];
      String[] code_bus=new String[50000];
  String[] code_credit=new String[50000];
      String[] code_work=new String[50000];
 
       String[] dic_size=new String[50000];
      String[] dic_bus=new String[50000];
  String[] dic_credit=new String[50000];
      String[] dic_work=new String[50000];
 
      int creditnumber;
String[] creditp=new String[50];
String[] style=new String[50];
int[] strlong=new int[50];
     String[][] datax=new String[500000][10];
 
    public static void main(String[] args) {
        pro r=new pro();
    }
 
    pro(){
 
 
 
        creditnumber=7;
        creditp[1]="year";
        creditp[2]="month";
        creditp[3]="credit";
        creditp[4]="bus";
        creditp[5]="work";
        creditp[6]="size";
        creditp[7]="value";
        style[1]="INTEGER";
        style[2]="INTEGER";
        style[3]="VARCHAR";
       style[4]="VARCHAR";
       style[5]="VARCHAR";
        style[6]="VARCHAR";
       style[7]="DOUBLE";
 
strlong[3]=5;
strlong[4]=5;
strlong[5]=5;
strlong[6]=5;
 
  String db,tab;
 
 
        db="mai";
        tab="mai";
 
 
        table sub7=new table();
        sub7.credit=creditp;
        sub7.creditnumber=creditnumber;
        sub7.style=style;
        sub7.strlong=strlong;
        sub7.makedata(db,tab);
 
int number_bus=0;
        int number_credit=0;
        int number_work=0;
        int number_size=0;
 
 
int tr;
    for(tr=1;tr<723;tr++){    
 
        readfile sub79=new readfile();
    sub79.makedata("gdata/"+tr+".txt", "UTF-8");
    data=sub79.data;
    datanumber=sub79.datanumber;
 
    String str;
 
        for(s=1;s<datanumber+1;s++){
 
        catchword sub8=new catchword();
        v[s]=sub8.makedata(data[s],"value");
        bus[s]=sub8.makedata(data[s],"bus");
        credit[s]=sub8.makedata(data[s],"credit");
        size[s]=sub8.makedata(data[s],"size");
        work[s]=sub8.makedata(data[s],"work");
        year[s]=sub8.makedata(data[s],"year");
        month[s]=sub8.makedata(data[s],"month");
        }
 
 
 
 
        int h,sx;
 
        for(s=1;s<datanumber+1;s++){
     h=0;
    for(sx=1;sx<number_size+1;sx++){
    if(size[s].equals(dic_size[sx]))h=100;     
     }
    if(h<50)number_size=number_size+1;
    if(h<50)dic_size[number_size]=size[s];
     }
 
 
 
  for(s=1;s<datanumber+1;s++){
    for(sx=1;sx<number_size+1;sx++){
    if(size[s].equals(dic_size[sx]))code_size[s]="s"+sx;     
     }
     }
 
 
 
    for(s=1;s<datanumber+1;s++){
     h=0;
    for(sx=1;sx<number_work+1;sx++){
    if(work[s].equals(dic_work[sx]))h=100;     
     }
    if(h<50)number_work=number_work+1;
    if(h<50)dic_work[number_work]=work[s];
     }
 
 
 
  for(s=1;s<datanumber+1;s++){
    for(sx=1;sx<number_work+1;sx++){
    if(work[s].equals(dic_work[sx]))code_work[s]="w"+sx;     
     }
     }
 
 
 
 
    for(s=1;s<datanumber+1;s++){
     h=0;
    for(sx=1;sx<number_bus+1;sx++){
    if(bus[s].equals(dic_bus[sx]))h=100;     
     }
    if(h<50)number_bus=number_bus+1;
    if(h<50)dic_bus[number_bus]=bus[s];
     }
 
 
 
  for(s=1;s<datanumber+1;s++){
    for(sx=1;sx<number_bus+1;sx++){
    if(bus[s].equals(dic_bus[sx]))code_bus[s]="b"+sx;     
     }
     }
 
 
 
    for(s=1;s<datanumber+1;s++){
     h=0;
    for(sx=1;sx<number_credit+1;sx++){
    if(credit[s].equals(dic_credit[sx]))h=100;     
     }
    if(h<50)number_credit=number_credit+1;
    if(h<50)dic_credit[number_credit]=credit[s];
     }
 
 
 
  for(s=1;s<datanumber+1;s++){
    for(sx=1;sx<number_credit+1;sx++){
    if(credit[s].equals(dic_credit[sx]))code_credit[s]="c"+sx;     
     }
     }
 
 
 
  sx=0;
 for(s=1;s<datanumber+1;s++){
 double p1=num(v[s]);
 if(p1>0){
     sx=sx+1;
        datax[sx][1]=""+year[s];
        datax[sx][2]=""+month[s];
        datax[sx][3]=""+code_credit[s];
        datax[sx][4]=""+code_bus[s];
 datax[sx][5]=""+code_work[s];
        datax[sx][6]=""+code_size[s];
       datax[sx][7]=""+p1;
 }
 }
 
 datanumber=sx;
 
 
  insert sub5=new insert();
        sub5.creditnumber=creditnumber;
        sub5.style=style;
        sub5.data=datax;
        sub5.datanumber=datanumber;
        sub5.makedata(db,tab);
 
    }
 
 
     for(s=1;s<number_credit+1;s++){
    System.out.println("c"+s+","+dic_credit[s]);    
    }
 
    for(s=1;s<number_bus+1;s++){
    System.out.println("b"+s+","+dic_bus[s]);    
    }
 
       for(s=1;s<number_work+1;s++){
    System.out.println("w"+s+","+dic_work[s]);    
    }
 
    for(s=1;s<number_size+1;s++){
    System.out.println("s"+s+","+dic_size[s]);    
    }
 
 
 
    }
 
 
 
    double num(String str){
 
    double nx;
 
    nx=0;
 
 try{
 
    nx=Double.parseDouble(str);
 
 }catch (Exception e) {}
 
 return nx;
 
 
 
}
 
 
}
 
 
 
 
package delta;
 
import java.sql.*; 
 
public class table{
 
    Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
int creditnumber;
String[] credit=new String[50];
String[] style=new String[50];
int[] strlong=new int[50];
 
 
 
 
    void makedata(String db,String tab){
 
 
 
        String str;
 
        str="";
        int s;
        for(s=1;s<creditnumber;s++){
        if(style[s].equals("INTEGER"))str=str+credit[s]+" "+style[s]+",";
        if(style[s].equals("VARCHAR"))str=str+credit[s]+" "+style[s]+"("+strlong[s]+"),";
        }
        s=creditnumber;
        if(style[s].equals("INTEGER"))str=str+credit[s]+" "+style[s];
        if(style[s].equals("VARCHAR"))str=str+credit[s]+" "+style[s]+"("+strlong[s]+")";
 
 
 
 
    String url = "jdbc:h2:"+db+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
 try{
 Class.forName("org.h2.Driver");
 
dbx = DriverManager.getConnection(url, usr, pwd); 
 
 
      stx = dbx.createStatement();
 
      String sqx = "CREATE TABLE " +tab+"("+str+")"; 
 
 
      stx.executeUpdate(sqx);
 
 } catch (Exception ex) { ex.printStackTrace();} 
 
 
 
 
 
 
    }
}
 
 
package delta;
 
import java.sql.*;
import java.io.*;
 
class insert {
 
    Connection dbx;   
Statement stx;   
String sqx; 
ResultSet  rsx; 
 
String[] style=new String[50];
int creditnumber;
  String[][] data=new String[5000][50];  
int datanumber;
 
int p;
 
    void makedata(String db,String tab) {
 
        String str;
 
        int s,sx;
 
        for(p=1;p<datanumber+1;p++){
 
 
       str="";
 
        for(sx=1;sx<creditnumber;sx++){
        if(style[sx].equals("VARCHAR"))str=str+change(data[p][sx])+",";
        if(style[sx].equals("INTEGER"))str=str+data[p][sx]+",";
        }
        sx=creditnumber;
        if(style[sx].equals("VARCHAR"))str=str+change(data[p][sx]);
        if(style[sx].equals("INTEGER"))str=str+data[p][sx];
 
    String url = "jdbc:h2:"+db+";create=true";   
String usr = "";   
String pwd = ""; 
 
 
 try{
 Class.forName("org.h2.Driver");
 
dbx = DriverManager.getConnection(url, usr, pwd); 
 
 
      stx = dbx.createStatement();
 
      String sql = "INSERT INTO "+tab+" VALUES("+str+")";
 
    int num = stx.executeUpdate(sql);
 
    stx.close();
 } catch (Exception ex) { ex.printStackTrace();} 
 
        }
 
 
  }
String change(String str){
String str1;
str1="'"+str+"'";
return str1;
}
}
 
最終更新:2016年05月15日 15:05