package sya;
import tool.*;
import java.io.*;
public class pro {
int s,datanumber;
String[] data=new String[50000];
String[] name=new String[50000];
String[] city=new String[50000];
String[] party=new String[50000];
int[] point=new int[500000];
int number_city=0;
int number;
String[] town=new String[5000];
String[] code=new String[50000];
String[] v=new String[50000];
String[][] vs=new String[2000][39];
int dicnumber=0;
String[] dic=new String[50];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
int tr;
for(tr=1;tr<12;tr++){
readfile sub=new readfile();
sub.makedata("data/"+tr+".txt","UTF-8");
data=sub.data;
datanumber=sub.datanumber;
for(s=1;s<datanumber+1;s++){
catchword sub2=new catchword();
city[s]=sub2.makedata(data[s], "pref");
code[s]=sub2.makedata(data[s], "code");
party[s]=sub2.makedata(data[s], "credit");
v[s]=sub2.makedata(data[s], "value");
}
int sx;
dicnumber=0;
dic[0]="";
for(s=1;s<datanumber+1;s++){
int h=0;
for(sx=0;sx<dicnumber+1;sx++){
if(party[s].equals(dic[sx]))h=100;
}
if(h<50)dicnumber=dicnumber+1;
if(h<50)dic[dicnumber]=party[s];
}
number_city=0;
for(s=1;s<datanumber+1;s++){
int h=0;
for(sx=0;sx<number_city+1;sx++){
if(code[s].equals(town[sx]))h=100;
}
if(h<50)number_city=number_city+1;
if(h<50)town[number_city]=code[s];
}
for(s=1;s<datanumber+1;s++){
int s1=0;
int s2=0;
for(sx=0;sx<number_city+1;sx++){
if(code[s].equals(town[sx]))s1=sx;
}
for(sx=0;sx<dicnumber+1;sx++){
if(party[s].equals(dic[sx]))s2=sx;
}
vs[s1][s2]=v[s];
}
System.out.println(dicnumber);
System.out.println(number_city);
writexml("gdata/"+tr+".txt");
}
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.print("");
for(sx=1;sx<dicnumber+1;sx++){
pw.print(",");
pw.print(dic[sx]);
}
pw.println("");
for(s=1;s<number_city+1;s++){
pw.print(town[s]);
for(sx=1;sx<dicnumber+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;
}
}
最終更新:2016年08月20日 14:23