package page;
import java.io.*;
public class pro {
int creditnumber;
String[] credit=new String[100];
int[] seat=new int[50000];
int[] sale=new int[50000];
int[] th=new int[50000];
int number;
int[] number_th=new int[5000];
String[] title=new String[50000];
int[] year=new int[50000];
int[] month=new int[50000];
int[] day=new int[50000];
String[] time=new String[50000];
String[] ch=new String[5000];
String[] thea=new String[50000];
int[][] subseat=new int[5000][100];
int[][] subsale=new int[5000][100];
int[][] subth=new int[5000][100];
String[][] subtitle=new String[5000][100];
int s,datanumber;
String[] data=new String[300000];
int[] subyear=new int[50000];
int[] submonth=new int[50000];
int[] subday=new int[50000];
String[] subtime=new String[50000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readx("data.csv");
int sx=0;
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
int h=0;
int y1=numx(x[0]);
int m1=numx(x[1]);
if(y1==2015)h=h+1;
if(m1==7)h=h+1;
if(h==2){
sx=sx+1;
year[sx]=y1;
month[sx]=m1;
day[sx]=numx(x[2]);
time[sx]=x[3];
thea[sx]=x[4];
title[sx]=x[5];
sale[sx]=numx(x[6]);
seat[sx]=numx(x[7]);
th[sx]=numx(x[8]);
}
}
int delta=sx;
int s1=1;
int s2=1;
subtitle[s1][s2]=title[1];
subsale[s1][s2]=sale[1];
subseat[s1][s2]=seat[1];
subth[s1][s2]=th[1];
for(s=2;s<delta+1;s++){
int h=0;
if(year[s]==year[s-1])h=h+1;
if(month[s]==month[s-1])h=h+1;
if(day[s]==day[s-1])h=h+1;
if(time[s].equals(time[s-1]))h=h+1;
if(thea[s].equals(thea[s-1]))h=h+1;
if(h<5)s1=s1+1;
if(h<5)s2=1;
if(h==5)s2=s2+1;
subsale[s1][s2]=sale[s];
subseat[s1][s2]=seat[s];
subtitle[s1][s2]=title[s];
subth[s1][s2]=th[s];
subyear[s1]=year[s];
submonth[s1]=month[s];
subday[s1]=day[s];
number_th[s1]=s2;
ch[s1]=thea[s];
subtime[s1]=time[s];
number=s1;
}
creditnumber=4;
credit[1]="題名";
credit[2]="販売";
credit[3]="席";
credit[4]="上映回数";
writehtml("ren.html");
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
void writehtml(String file){
int s,sx,tr;
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>");
for(tr=1;tr<number+1;tr++){
pw.println("<h1>"+ch[tr]+":"+subyear[tr]+"年"+submonth[tr]+"月"+subday[tr]+"日"+subtime[tr]+"</h1>");
pw.print("<table rules=\"all\">");
pw.print("<tr>");
pw.print("<td>");
pw.print("ランキング");
pw.print("</td>");
for(sx=1;sx<creditnumber+1;sx++){
pw.print("<th>");
pw.print(credit[sx]);
pw.print("</th>");
}
pw.println("</tr>");
for(s=1;s<number_th[tr]+1;s++){
pw.print("<tr>");
pw.print("<th>");
pw.print(s);
pw.print("</th>");
pw.print("<td>");
pw.print(subtitle[tr][s]);
pw.print("</td>");
pw.print("<td>");
pw.print(subsale[tr][s]);
pw.print("</td>");
pw.print("<td>");
pw.print(subseat[tr][s]);
pw.print("</td>");
pw.print("<td>");
pw.print(subth[tr][s]);
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("入出力エラーです。"); }
}
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;
}
}
最終更新:2016年07月08日 21:14