package don;
import tool.*;
public class pro {
double[][] a=new double[300][300];
double[] y=new double[300];
double[][] beta=new double[300][300];
double[] c=new double[300];
double[] im=new double[300];
double[] ex=new double[300];
double[] imx=new double[300];
double[][] inp=new double[300][300];
int number;
String[] data=new String[50000];
int s,sx,datanumber,tx;
String[] month=new String[50000];
String[] pref=new String[50000];
String[] year=new String[50000];
String[] credit=new String[50000];
double[] v=new double[30000];
int number_pref,number_credit;
String[] dic_pref=new String[5000];
String[] dic_credit=new String[5000];
String[] code_pref=new String[30000];
String[] code_credit=new String[30000];
double[] de=new double[300];
double[] tax=new double[300];
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 t=new pro();
}
pro(){
creditnumber=5;
creditp[1]="year";
creditp[2]="month";
creditp[3]="pref";
creditp[4]="credit";
creditp[5]="value";
style[1]="INTEGER";
style[2]="INTEGER";
style[4]="VARCHAR";
style[3]="VARCHAR";
style[5]="VARCHAR";
strlong[5]=20;
strlong[4]=5;
strlong[3]=5;
String db,tab;
db="jyu";
tab="jyu";
table sub7=new table();
sub7.credit=creditp;
sub7.creditnumber=creditnumber;
sub7.style=style;
sub7.strlong=strlong;
sub7.makedata(db,tab);
number_pref=0;
number_credit=0;
int pp;
for(pp=1;pp<123;pp++){
readfile sub71=new readfile();
sub71.makedata("data/"+pp+".txt", "UTF-8");
data=sub71.data;
datanumber=sub71.datanumber;
for(s=1;s<datanumber+1;s++){
catchword sub8=new catchword();
pref[s]=sub8.makedata(data[s],"pref");
year[s]=sub8.makedata(data[s],"year");
month[s]=sub8.makedata(data[s],"month");
credit[s]=sub8.makedata(data[s],"credit");
String str=sub8.makedata(data[s],"value");
v[s]=Double.parseDouble(str);
}
int h;
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;
}
}
for(s=1;s<datanumber+1;s++){
h=0;
for(sx=1;sx<number_pref+1;sx++){
if(pref[s].equals(dic_pref[sx]))h=100;
}
if(h<50)number_pref=number_pref+1;
if(h<50)dic_pref[number_pref]=pref[s];
}
for(s=1;s<datanumber+1;s++){
for(sx=1;sx<number_pref+1;sx++){
if(pref[s].equals(dic_pref[sx]))code_pref[s]="p"+sx;
}
}
for(s=1;s<datanumber+1;s++){
datax[s][1]=year[s];
datax[s][2]=month[s];
datax[s][3]=code_pref[s];
datax[s][4]=code_credit[s];
datax[s][5]=""+v[s];
}
insert sub5=new insert();
sub5.creditnumber=creditnumber;
sub5.style=style;
sub5.data=datax;
sub5.datanumber=datanumber;
sub5.makedata(db,tab);
}
for(sx=1;sx<number_credit+1;sx++){
System.out.println("c"+sx+","+dic_credit[sx]);
}
for(sx=1;sx<number_pref+1;sx++){
System.out.println("p"+sx+","+dic_pref[sx]);
}
}
}
package don;
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;
}
}
package don;
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();}
}
}
最終更新:2015年08月26日 15:00