package ufo;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class pro {
int s,datanumber;
String[] data=new String[500000];
String[] subdata=new String[50000];
String[] date=new String[5000];
String[] name=new String[500000];
int number;
String[] id=new String[5000];
int[] point=new int[5000];
int[] v=new int[5000];
int dicnumber=0;
String[] time=new String[50000];
String[] week=new String[50000];
String[] code=new String[50000];
String[] title=new String[50000];
String[] sta=new String[50000];
String[] a=new String[50000];
String[] b=new String[50000];
String[] y1=new String[50000];
String[] m1=new String[50000];
String[] y2=new String[50000];
String[] m2=new String[50000];
String[] k1=new String[50000];
String[] k2=new String[50000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readx("data.csv");
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
code[s]=x[0];
title[s]=x[1];
sta[s]=x[2];
String x3="";
if(x.length>3)x3=x[3];
int p1=x3.indexOf("曜");
int p4=x3.indexOf("曜",p1+1);
if(p4>0)p1=p4;
if(p1<0)p1=x3.indexOf("日");
week[s]="";
if(p1>-1)week[s]=x3.substring(0,p1+1);
int p2=0;
x3=x3.replace("→","-");
if(p1>0)p2=x3.indexOf("(",p1);
time[s]="";
if(p2>0)time[s]=x3.substring(p1+1,p2);
String x4="";
if(x.length>4)x4=x[4];
x4=x4.replace("〜","-");
String[] y=x4.split("-");
a[s]="";
if(y.length>0)a[s]=y[0];
b[s]="";
if(y.length>1)b[s]=y[1];
}
for(s=2;s<datanumber+1;s++){
int p1=a[s].indexOf("年");
int p2=-1;
if(p1>-1)p2=a[s].indexOf("月",p1);
y1[s]="";
if(p1>-1)y1[s]=a[s].substring(0,p1);
m1[s]="";
if(p2>-1)m1[s]=a[s].substring(p1+1,p2);
}
for(s=2;s<datanumber+1;s++){
int p1=b[s].indexOf("年");
int p2=-1;
if(p1>-1)p2=b[s].indexOf("月",p1);
y2[s]="";
if(p1>-1)y2[s]=b[s].substring(0,p1);
m2[s]="";
if(p2>-1)m2[s]=b[s].substring(p1+1,p2);
if(y2[s].indexOf("同")>-1)y2[s]=y1[s];
}
for(s=2;s<datanumber+1;s++){
time[s]=time[s].replace("日","");
time[s]=time[s].replace("頃","");
time[s]=time[s].replace("〜","-");
String[] z=time[s].split("-");
k1[s]="";
k2[s]="";
if(z.length>0)k1[s]=z[0];
if(z.length>1)k2[s]=z[1];
subdata[s]=code[s]+","+title[s]+","+sta[s]+","+week[s]+","+y1[s]+","+m1[s]+","+y2[s]+","+m2[s]+","+k1[s]+","+k2[s];
}
writexml("ren.txt");
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(s=2;s<datanumber+1;s++){
pw.println(subdata[s]);
}
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月29日 18:28