アットウィキロゴ

dao999

package base;
 
import tool.*;
import java.io.*;
 
public class pro {
 
  int s,datanumber;
  String[] data=new String[50];
     String[] pos=new String[50];
   String[] name=new String[50];
     String[][] point=new String[50][20];
 
    public static void main(String[] args) {
        pro t=new pro();
    }
    pro(){
 
        int tr;
 for(tr=1;tr<484;tr++){
 
     readfile sub7=new readfile();
        sub7.makedata("visit_c/"+tr+".txt","UTF-8");
        data=sub7.data;
        datanumber=sub7.datanumber; 
 
        int sx;
        for(s=1;s<datanumber-1;s++){
         for(sx=1;sx<20;sx++){
         point[s][sx]="△";    
         }   
         }
 
        for(s=1;s<datanumber-1;s++){
        String[] x=data[s].split(",");
        for(sx=0;sx<x.length;sx++){
        if(sx==0)pos[s]=x[sx];
        if(sx==1)name[s]=x[sx];
        if(sx>7)point[s][sx-7]=x[sx];
 
        }
 
        }
 
      for(s=1;s<datanumber-1;s++){
      pos[s]=pos[s].replace("<tr>","");
      name[s]=name[s].replace("<td class=\"left\">","");
     for(sx=1;sx<20;sx++){
      point[s][sx]=point[s][sx].replace("&nbsp;","△");   
      point[s][sx]=point[s][sx].replace("……","△");  
     point[s][sx]=change(point[s][sx]);
     }
     }
 
 
    writecsv("visit_cc/"+tr+".txt");
 }
 
 
 
 
    }
 
    String change(String str){
 
        int n;
        for(n=1;n<11;n++){
        str=rev(str);    
        }
 
        str=str.replace(" ","");
 
        return str;
    }
 
 String rev(String str){
 
        if(str==null)str="";
 
        int p1=str.indexOf("<");
        int p2=str.indexOf(">",p1);
        String strx="";
        if(p2>-1)strx=str.substring(p1,p2+1);
        str=str.replace(strx,"");
 
        return str;
    }    
 
       void writecsv(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<datanumber-1;s++){  
pw.print(name[s]);
pw.print(","); 
pw.print(pos[s]); 
for(sx=1;sx<20;sx++){ 
pw.print(","); 
pw.print(point[s][sx]);   
}
pw.println(""); 
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
}
最終更新:2016年10月06日 05:57