package don;
import java.io.File;
import tool.*;
import java.io.*;
public class pro {
int s,datanumber;
String[] data=new String[60000];
String[] bus=new String[60000];
String[] index=new String[60000];
String[] credit=new String[60000];
double[] v=new double[60000];
String[] dic_index=new String[6000];
String[] dic_credit=new String[6000];
int number_index,number_credit;
String[] code_index=new String[6000];
String[] code_credit=new String[6000];
double[][] vs=new double[500][500];
int number;
String[] dic=new String[700];
public static void main(String[] args) {
pro test=new pro();
}
pro(){
bus[ 1 ]=" 耕種農業 ";
bus[ 2 ]=" 畜産 ";
bus[ 3 ]=" 農業サービス ";
bus[ 4 ]=" 林業 ";
bus[ 5 ]=" 漁業 ";
bus[ 6 ]=" 金属鉱物 ";
bus[ 7 ]=" 非金属鉱物 ";
bus[ 8 ]=" 石炭・原油・天然ガス ";
bus[ 9 ]=" 食料品 ";
bus[ 10 ]=" 飲料 ";
bus[ 11 ]=" 飼料・有機質肥料(除別掲) ";
bus[ 12 ]=" たばこ ";
bus[ 13 ]=" 繊維工業製品 ";
bus[ 14 ]=" 衣服・その他の繊維既製品 ";
bus[ 15 ]=" 製材・木製品 ";
bus[ 16 ]=" 家具・装備品 ";
bus[ 17 ]=" パルプ・紙・板紙・加工紙 ";
bus[ 18 ]=" 紙加工品 ";
bus[ 19 ]=" 印刷・製版・製本 ";
bus[ 20 ]=" 化学肥料 ";
bus[ 21 ]=" 無機化学工業製品 ";
bus[ 22 ]=" 石油化学基礎製品 ";
bus[ 23 ]=" 有機化学工業製品(除石油化学基礎製品) ";
bus[ 24 ]=" 合成樹脂 ";
bus[ 25 ]=" 化学繊維 ";
bus[ 26 ]=" 医薬品 ";
bus[ 27 ]=" 化学最終製品(除医薬品) ";
bus[ 28 ]=" 石油製品 ";
bus[ 29 ]=" 石炭製品 ";
bus[ 30 ]=" プラスチック製品 ";
bus[ 31 ]=" ゴム製品 ";
bus[ 32 ]=" なめし革・毛皮・同製品 ";
bus[ 33 ]=" ガラス・ガラス製品 ";
bus[ 34 ]=" セメント・セメント製品 ";
bus[ 35 ]=" 陶磁器 ";
bus[ 36 ]=" その他の窯業・土石製品 ";
bus[ 37 ]=" 銑鉄・粗鋼 ";
bus[ 38 ]=" 鋼材 ";
bus[ 39 ]=" 鋳鍛造品 ";
bus[ 40 ]=" その他の鉄鋼製品 ";
bus[ 41 ]=" 非鉄金属製錬・精製 ";
bus[ 42 ]=" 非鉄金属加工製品 ";
bus[ 43 ]=" 建設・建築用金属製品 ";
bus[ 44 ]=" その他の金属製品 ";
bus[ 45 ]=" 一般産業機械 ";
bus[ 46 ]=" 特殊産業機械 ";
bus[ 47 ]=" その他の一般機械器具及び部品 ";
bus[ 48 ]=" 事務用・サービス用機器 ";
bus[ 49 ]=" 産業用電気機器 ";
bus[ 50 ]=" 電子応用装置・電気計測器 ";
bus[ 51 ]=" その他の電気機器 ";
bus[ 52 ]=" 民生用電気機器 ";
bus[ 53 ]=" 通信機械・同関連機器 ";
bus[ 54 ]=" 電子計算機・同付属装置 ";
bus[ 55 ]=" 半導体素子・集積回路 ";
bus[ 56 ]=" その他の電子部品 ";
bus[ 57 ]=" 乗用車 ";
bus[ 58 ]=" その他の自動車 ";
bus[ 59 ]=" 自動車部品・同付属品 ";
bus[ 60 ]=" 船舶・同修理 ";
bus[ 61 ]=" その他の輸送機械・同修理 ";
bus[ 62 ]=" 精密機械 ";
bus[ 63 ]=" その他の製造工業製品 ";
bus[ 64 ]=" 再生資源回収・加工処理 ";
bus[ 65 ]=" 建築 ";
bus[ 66 ]=" 建設補修 ";
bus[ 67 ]=" 公共事業 ";
bus[ 68 ]=" その他の土木建設 ";
bus[ 69 ]=" 電力 ";
bus[ 70 ]=" ガス・熱供給 ";
bus[ 71 ]=" 水道 ";
bus[ 72 ]=" 廃棄物処理 ";
bus[ 73 ]=" 卸売 ";
bus[ 74 ]=" 小売 ";
bus[ 75 ]=" 金融 ";
bus[ 76 ]=" 保険 ";
bus[ 77 ]=" 不動産仲介及び賃貸 ";
bus[ 78 ]=" 住宅賃貸料 ";
bus[ 79 ]=" 住宅賃貸料(帰属家賃) ";
bus[ 80 ]=" 鉄道輸送 ";
bus[ 81 ]=" 道路輸送(除自家輸送) ";
bus[ 82 ]=" 水運 ";
bus[ 83 ]=" 航空輸送 ";
bus[ 84 ]=" 貨物利用運送 ";
bus[ 85 ]=" 倉庫 ";
bus[ 86 ]=" 運輸付帯サービス ";
bus[ 87 ]=" 通信 ";
bus[ 88 ]=" 放送 ";
bus[ 89 ]=" 情報サービス ";
bus[ 90 ]=" インターネット附随サービス ";
bus[ 91 ]=" 映像・文字情報制作 ";
bus[ 92 ]=" 公務 ";
bus[ 93 ]=" 教育 ";
bus[ 94 ]=" 研究 ";
bus[ 95 ]=" 医療・保健 ";
bus[ 96 ]=" 社会保障 ";
bus[ 97 ]=" 介護 ";
bus[ 98 ]=" その他の公共サービス ";
bus[ 99 ]=" 広告 ";
bus[ 100 ]=" 物品賃貸サービス ";
bus[ 101 ]=" 自動車・機械修理 ";
bus[ 102 ]=" その他の対事業所サービス ";
bus[ 103 ]=" 娯楽サービス ";
bus[ 104 ]=" 飲食店 ";
bus[ 105 ]=" 宿泊業 ";
bus[ 106 ]=" 洗濯・理容・美容・浴場業 ";
bus[ 107 ]=" その他の対個人サービス ";
bus[ 108 ]=" 事務用品 ";
bus[ 109 ]=" 分類不明 ";
File g=new File("gdata");
String[] gx=g.list();
int tr;
for(tr=0;tr<47;tr++){
readfile sub=new readfile();
sub.makedata("gdata/"+gx[tr],"UTF-8");
data=sub.data;
datanumber=sub.datanumber;
System.out.println(gx[tr]);
dic sub77=new dic();
sub77.makedata("dic/"+gx[tr]);
dic=sub77.dic;
number=sub77.number;
for(s=1;s<datanumber+1;s++){
catchword sub2=new catchword();
index[s]=sub2.makedata(data[s],"index");
credit[s]=sub2.makedata(data[s],"credit");
String str=sub2.makedata(data[s],"value");
v[s]=num(str);
}
int h,sx;
number_index=0;
for(s=1;s<datanumber+1;s++){
h=0;
for(sx=1;sx<number_index+1;sx++){
if(index[s].equals(dic_index[sx]))h=100;
}
if(h<50)number_index=number_index+1;
if(h<50)dic_index[number_index]=index[s];
}
for(s=1;s<number_index+1;s++){
code_index[s]="";
}
number_credit=0;
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];
}
System.out.println(number_credit);
for(s=1;s<number_index+1;s++){
h=0;
if(dic_index[s].indexOf("雇")>-1)h=100;
if(dic_index[s].indexOf("社会")>-1)h=0;
if(h>40)code_index[s]="w";
}
for(s=1;s<number_index+1;s++){
h=0;
if(dic_index[s].indexOf("生産")>-1)h=h+1;
if(dic_index[s].indexOf("額")>-1)h=h+1;
if(h==2)code_index[s]="y";
}
for(s=1;s<number+1;s++){
code_index[s]=dic[s];
}
for(s=1;s<datanumber+1;s++){
int s1=0;
int s2=0;
for(sx=1;sx<number_credit+1;sx++){
if(credit[s].equals(dic_credit[sx]))s2=sx;
}
for(sx=1;sx<number_index+1;sx++){
if(index[s].equals(dic_index[sx]))s1=sx;
}
vs[s1][s2]=v[s];
}
String str=gx[tr].replace("txt","csv");
System.out.println(str);
writecsv("io/"+str);
}
}
void writecsv(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.print("産業");
pw.print(",");
pw.print("コード");
for(sx=1;sx<number_credit+1;sx++){
pw.print(",");
pw.print(dic_credit[sx]);
}
pw.println("");
for(s=1;s<number_index+1;s++){
pw.print(dic_index[s]);
pw.print(",");
pw.print(code_index[s]);
for(sx=1;sx<number_credit+1;sx++){
pw.print(",");
pw.print(vs[s][sx]);
}
pw.println("");
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
double num(String str){
double nx;
nx=0;
try{
nx=Double.parseDouble(str);
}catch (Exception e) {}
return nx;
}
}
package don;
import tool.catchword;
import tool.readfile;
public class dic {
int s,datanumber;
String[] data=new String[50000];
String[] dic=new String[50000];
int number;
void makedata(String file ){
readfile sub=new readfile();
sub.makedata(file,"UTF-8");
data=sub.data;
datanumber=sub.datanumber;
for(s=1;s<datanumber+1;s++){
catchword sub2=new catchword();
dic[s]="b"+ sub2.makedata(data[s],"code");
}
number=datanumber;
}
}
最終更新:2016年05月17日 18:11