package tv;
import java.io.*;
public class Tv {
int s,datanumber;
String[] data=new String[200000];
String[] date=new String[200000];
String[] y=new String[200000];
String[] m=new String[200000];
String[] d=new String[200000];
String[] w=new String[200000];
int[] h1=new int[200000];
int[] m1=new int[200000];
int[] h2=new int[200000];
int[] m2=new int[200000];
String[] t=new String[200000];
String[] sub=new String[200000];
String[] act=new String[200000];
public static void main(String[] args) {
Tv te=new Tv();
}
Tv(){
readx("tok.csv");
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
date[s]=x[0];
t[s]=x[1];
sub[s]=x[2];
act[s]=x[3];
}
for(s=2;s<datanumber+1;s++){
y[s]="";
m[s]="";
date[s]=date[s].replace("45年の愛〜","");
date[s]=date[s].replace("『今年もあの日がやってきた!ほか","");
int px=date[s].indexOf("年");
if(px>5)date[s]=date[s].substring(px-4,date[s].length());
System.out.println(date[s]);
if(px>-1){
String[] x=date[s].split("〜");
String str=x[0];
int p1=str.indexOf("年");
int p2=str.indexOf("月");
int p3=str.indexOf("日");
y[s]=str.substring(0,p1);
m[s]=str.substring(p1+1,p2);
d[s]=str.substring(p2+1,p3);
int p4=str.indexOf("(");
int p5=str.indexOf(")");
w[s]=str.substring(p4+1,p5);
int p6=str.indexOf(":");
int p7=str.length();
String str2=str.substring(p5+1,p6);
h1[s]=numx(str2);
str2=str.substring(p6+1,p7);
m1[s]=numx(str2);
str=x[1];
p1=str.indexOf(")");
int z=0;
if(p1>-1)z=100;
if(p1>-1)str=str.substring(p1+1,x[1].length());
p6=str.indexOf(":");
p7=str.length();
String strx=str.substring(0,p6);
h2[s]=numx(strx);
strx=str.substring(p6+1,p7);
m2[s]=numx(strx);
if(z>50)h2[s]=24+h2[s];
}
}
writexml("ren.csv");
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.println("n,y,m,d,w,h1,m1,h2,m2,t,s,a");
for(s=2;s<datanumber+1;s++){
if(y[s].length()>0){
pw.print(s-1);
pw.print(",");
pw.print(y[s]);
pw.print(",");
pw.print(m[s]);
pw.print(",");
pw.print(d[s]);
pw.print(",");
pw.print(w[s]);
pw.print(",");
pw.print(h1[s]);
pw.print(",");
pw.print(m1[s]);
pw.print(",");
pw.print(h2[s]);
pw.print(",");
pw.print(m2[s]);
pw.print(",");
pw.print(t[s]);
pw.print(",");
pw.print(sub[s]);
pw.print(",");
pw.println(act[s]);
}
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
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年08月30日 21:43