package ken;
import java.io.*;
public class pro {
int maxx=100;
int maxy=100;
String[][] mat=new String[200][200];
int fastline=0;
int lastline=0;
String[] pref=new String[200];
int prefline;
int[] c=new int[13];
int datanumber;
String[] data=new String[200];
String[] subdata=new String[2000];
String[] namex=new String[200];
public static void main(String[] args) {
pro r=new pro();
}
pro(){
namex[1]="北海道";
namex[2]="青森";
namex[3]="岩手";
namex[4]="宮城";
namex[5]="秋田";
namex[6]="山形";
namex[7]="福島";
namex[8]="茨城";
namex[9]="栃木";
namex[10]="群馬";
namex[11]="埼玉";
namex[12]="千葉";
namex[13]="東京";
namex[14]="神奈川";
namex[15]="新潟";
namex[16]="富山";
namex[17]="石川";
namex[18]="福井";
namex[19]="山梨";
namex[20]="長野";
namex[21]="岐阜";
namex[22]="静岡";
namex[23]="愛知";
namex[24]="三重";
namex[25]="滋賀";
namex[26]="京都";
namex[27]="大阪";
namex[28]="兵庫";
namex[29]="奈良";
namex[30]="和歌山";
namex[31]="鳥取";
namex[32]="島根";
namex[33]="岡山";
namex[34]="広島";
namex[35]="山口";
namex[36]="徳島";
namex[37]="香川";
namex[38]="愛媛";
namex[39]="高知";
namex[40]="福岡";
namex[41]="佐賀";
namex[42]="長崎";
namex[43]="熊本";
namex[44]="大分";
namex[45]="宮崎";
namex[46]="鹿児島";
namex[47]="沖縄";
int tr;
for(tr=1;tr<21;tr++){
readxls sub2=new readxls();
sub2.maxx=maxx;
sub2.maxy=maxy;
sub2.makedata("data.xls",tr);
mat=sub2.mat;
writehtml("ren.html");
int s,sx;
prefline=0;
fastline=0;
for(s=1;s<21;s++){
for(sx=1;sx<11;sx++){
int h=0;
if(mat[s][sx].indexOf("海")>-1)h=h+1;
if(mat[s][sx].indexOf("道")>-1)h=h+1;
if(h==2)fastline=s;
if(h==2)prefline=sx;
}
}
System.out.println(fastline);
lastline=0;
for(s=fastline;s<70;s++){
int h=0;
if(mat[s][prefline].indexOf("沖")>-1)h=h+1;
if(mat[s][prefline].indexOf("縄")>-1)h=h+1;
if(h==2)lastline=s;
}
System.out.println(lastline);
sx=0;
for(s=fastline;s<lastline;s++){
sx=sx+1;
pref[sx]=mat[s][prefline];
}
c[1]=2;
c[2]=6;
c[3]=7;
c[4]=8;
c[5]=9;
c[6]=10;
c[7]=11;
c[8]=12;
c[9]=13;
c[10]=14;
c[11]=15;
c[12]=19;
writexml("data/"+tr+".txt");
}
int s;
String str="year,bus";
for(s=1;s<48;s++){
str=str+","+namex[s];
}
int sx=1;
subdata[sx]=str;
for(tr=1;tr<21;tr++){
readx("data/"+tr+".txt");
for(s=1;s<datanumber+1;s++){
sx=sx+1;
subdata[sx]=(tr+1954)+","+data[s];
}
System.out.println(data[1]);
}
datanumber=sx;
writecsv("ren.txt");
}
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;
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(sx=1;sx<13;sx++){
pw.print("b"+sx);
for(s=fastline;s<lastline+1;s++){
int s1=c[sx]+prefline;
pw.print(",");
pw.print(mat[s][s1]);
}
pw.println("");
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void writecsv(String file){
int s;
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 writehtml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.println("<html>");
pw.println("<head>");
pw.println("<meta charset=\"UTF-8\">");
pw.println("</head>");
pw.println("<body>");
pw.print("<table rules=\"all\">");
pw.print("<tr>");
pw.print("<td>");
pw.print("");
pw.print("</td>");
for(sx=1;sx<maxx+1;sx++){
pw.print("<th>");
pw.print(sx);
pw.print("</th>");
}
pw.println("</tr>");
for(s=1;s<maxy+1;s++){
pw.print("<tr>");
pw.print("<th>");
pw.print(s);
pw.print("</th>");
for(sx=1;sx<maxx+1;sx++){
pw.print("<td>");
pw.print(mat[s][sx]);
pw.print("</td>");
}
pw.println("</tr>");
}
pw.println("</table>");
pw.println("</body>");
pw.println("</html>");
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
最終更新:2017年03月20日 22:17