アットウィキロゴ

データ処理地下k

package delta;
 
 
 
import java.io.*;
 
 
public class pro {
 
    int s,sx;
    int maxx,maxy;
     String[][] mat=new String[5000][5000]; 
    String str;
     String[] credit=new String[500];
      String[][] count=new String[500][50]; 
      String[] index=new String[500];
  String[] code=new String[500];
   String[] subcode=new String[500];
   String[] topic=new String[500];
 
      String[] delta=new String[500];
  int fastline,lastline;
  int tr;
 
    public static void main(String[] args) {
        pro test=new pro();
    }
 
   pro(){ 
 
 
     for(tr=2003;tr<2016;tr++){  
 
       readxls sub=new readxls();
       sub.maxx=50;
       sub.maxy=200;
       sub.makedata("data/"+tr+".xls",0);
   mat=sub.mat;
 
 
 
for(sx=2;sx<7;sx++){
str=mat[2][sx];       
credit[sx]=str;
}
 
fastline=4;
lastline=0;
 
for(s=1;s<100;s++){
if(mat[s][1].indexOf("宅")>-1)lastline=s;
if(mat[s][1].indexOf("下")>-1)lastline=s;
}
 
for(s=fastline;s<lastline+1;s++){     
index[s]=mat[s][1].replace(" ","");
index[s]=mat[s][1].replace(" ","");
}
 
 
for(s=fastline;s<lastline+1;s++){
topic[s]="";
int h=0;
if(index[s].indexOf("〔")>-1)h=100;
if(index[s].indexOf("(")>-1)h=100;
if(h<50)topic[s]=index[s];
}
 
 
code[fastline-1]="";
for(s=fastline;s<lastline+1;s++){
code[s]="";
if(index[s].indexOf("〔")>-1)code[s]=index[s];        
if(code[s].length()<1)code[s]=code[s-1];
}
 
 
 
 
 
subcode[fastline]="";
for(s=fastline+1;s<lastline+1;s++){     
subcode[s]="";
if(index[s].indexOf("(")>-1)subcode[s]=index[s];
}
 
 
int h;
 
for(s=fastline+1;s<lastline+1;s++){      
h=0;
if(code[s].equals(code[s-1]))h=h+1;
if(subcode[s].length()<1)h=h+1;
if(h==2)subcode[s]=subcode[s-1];
}
 
for(s=fastline;s<lastline+1;s++){
topic[s]="";
h=0;    
if(index[s].indexOf("〔")>-1)h=100;
if(index[s].indexOf("(")>-1)h=100;   
if(h<50)topic[s]=index[s];
}
 
for(s=fastline;s<lastline+1;s++){
code[s]=code[s].replace("〔","");
code[s]=code[s].replace("〕","");
}
 
for(s=fastline;s<lastline+1;s++){
subcode[s]=subcode[s].replace("(","");
subcode[s]=subcode[s].replace(")","");
}
 
 
 
 
 
writex("gdata/"+tr+".txt");
     }
 
 
}
 
 
  void writex(String file){ 
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=fastline;s<lastline+1;s++){ 
if(topic[s].length()>0){
for(sx=2;sx<7;sx++){ 
pw.print("<year>");
pw.print(tr);
pw.print("</year>");
pw.print("<index>");
pw.print(code[s]);
pw.print("</index>");
pw.print("<subindex>");
pw.print(subcode[s]);
pw.print("</subindex>");
pw.print("<topic>");
pw.print(topic[s]);
pw.print("</topic>");
pw.print("<credit>");
pw.print(credit[sx]);
pw.print("</credit>");
pw.print("<value>");
pw.print(mat[s][sx]);
pw.println("</value>");
}
}
} 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
 
}
 
package delta;
 
 
import java.io.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
 
 
public class readxls {
 
    int maxx,maxy;
   Cell cc;
   String[][] mat=new String[5000][5000]; 
 
 void makedata(String file,int number){   
 
 
 
      try{
 
     FileInputStream is = new FileInputStream(file);
     Workbook wb = new HSSFWorkbook(is);
      Sheet sh = wb.getSheetAt(number);
 
      int s,sx,j,hh;
      String bb;
    for(s=1;s<maxy+1;s++){
      for(sx=1;sx<maxx+1;sx++){
     mat[s][sx]="";
      }
    }
 
  for(s=1;s<maxy+1;s++){
  Row row = sh.getRow(s-1);
  j=0;
  if(row==null)j=100;
  if(j<50){
  for(sx=1;sx<maxx+1;sx++){  
 cc = row.getCell(sx-1);
  hh=0;
  if(cc==null)hh=100;
  if(hh<50){
   int type =cc.getCellType();
       bb="";
       if(type==1)bb=cc.getStringCellValue();
        if(type==0)bb=""+cc.getNumericCellValue();
   mat[s][sx]=bb;    
  }}}}
 
 
 
 
 
 
  } catch (Exception e) {e.printStackTrace();}
 
 
 
 
 
 
 
 }
}
 
最終更新:2016年05月16日 13:54