アットウィキロゴ

999;:

package movie3;
 
import java.io.BufferedWriter;
import tool.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
 
public class pro {
 
     String[] subdata=new String[50000];
      int s,datanumber;
       String[] data=new String[5000];
    int[] year=new int[5000000];
    int[] month=new int[5000000];
    int[] day=new int[5000000];
    String[] th=new String[5000000];
    String[] v1=new String[5000000];
    String[] v2=new String[5000000];
    String[] v3=new String[5000000];
     String[] time=new String[5000000];
     String[] code=new String[5000000];
      String[] name=new String[5000000];
  String[] date=new String[5000];
       String[] d=new String[5000];
       int[] sale=new int[500];
    public static void main(String[] args) {
        pro test=new pro();
    }
    pro(){
 
        File f=new File("data");
        String[] ff=f.list();
 
        int tr;
        for(tr=0;tr<ff.length;tr++){
 
        readfile sub=new readfile();
        sub.makedata("data/"+ff[tr],"UTF-8");
        data=sub.data;
        datanumber=sub.datanumber;
 
         for(s=1;s<datanumber+1;s++){
 
 
          String[] x=data[s].split(",");
 
        name[s]=x[5];
        year[s]=numx(x[0]);
        month[s]=numx(x[1]);
        day[s]=numx(x[2]);
        th[s]=x[4];
        v1[s]=x[6];
        v2[s]=x[7];
        v3[s]=x[8];
        time[s]=x[3];
        code[s]="";
      if(x.length>9)code[s]=x[9];
      }
 
 
 for(s=1;s<datanumber+1;s++){
 d[s]=year[s]+"年"+month[s]+"月"+day[s]+"日";    
 }
 
        int sx,number;
 
        number=0;
 
        for(s=1;s<datanumber+1;s++){
int h=0;
            for(sx=1;sx<number+1;sx++){  
  if(d[s].equals(date[sx]))h=100;      
        }
        if(h<50)number=number+1;
         if(h<50)date[number]=d[s];
        }
 
   for(sx=1;sx<number+1;sx++){  
sale[sx]=0;  
        }
 
 
     for(s=1;s<datanumber+1;s++){
     for(sx=1;sx<number+1;sx++){  
  if(d[s].equals(date[sx]))sale[sx]=sale[sx]+numx(v1[s]);      
        }
        }
 
   String str=name[1]+","+code[1]+","+date[1];  
   if(number>150)number=150;
 
   for(s=1;s<number+1;s++){
   str=str+","+sale[s];    
   }     
   for(s=number+1;s<151;s++){
   str=str+",0";    
   }        
   subdata[tr+1]=str;
 
        }
 
datanumber=ff.length;
 
        writexml("data.txt");
 
    }
 
     int numx(String str){
 
    int nx;
 
    nx=0;
 
 try{
 
    nx=Integer.parseInt(str);
 
 }catch (Exception e) {}
 
 return nx;
 
 
 
}
 
  void writexml(String file){ 
 
    int s,sx;
 
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("入出力エラーです。"); } 
 
 
}    
}
 
最終更新:2017年01月15日 14:31