package artist3;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.*;
public class pro {
String[] data=new String[50000];
int s,datanumber,number;
String[] title=new String[50000];
String[] code=new String[50000];
String[] artist=new String[5000];
String[] subdata=new String[500000];
int[] point=new int[500000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readx("data.csv");
System.out.println(datanumber);
for(s=1;s<datanumber;s++){
String[] x=data[s+1].split(",");
title[s]=x[0];
code[s]=x[1];
if(data[s+1].indexOf("その他")>-1)point[s]=100;
if(data[s+1].indexOf("9999,")>-1)point[s]=100;
}
int n=0;
number=datanumber-1;
int tr;
for(tr=1;tr<number+1;tr++){
readx("data/"+code[tr]+".txt");
String str="";
for(s=1;s<datanumber;s++){
if(data[s].indexOf("主な演出")>-1)str=data[s+1];
}
str=chx(str);
String[] x=str.split("、");
for(s=0;s<x.length;s++){
x[s]=clean_str(x[s]);
int p1=x[s].indexOf("(");
if(p1>-1)x[s]=x[s].substring(0,p1);
p1=x[s].indexOf("(");
if(p1>-1)x[s]=x[s].substring(0,p1);
x[s]=x[s].replace(" ","");
if(x[s].indexOf(")")>-1)x[s]="";
}
int sx=0;
for(s=0;s<x.length;s++){
if(x[s].length()>1)sx=sx+1;
if(x[s].length()>1)artist[sx]=x[s].trim();
}
int number_artist=sx;
if(point[tr]<59){
for(s=1;s<number_artist+1;s++){
n=n+1;
subdata[n]=title[tr]+","+code[tr]+","+artist[s];
}
}
}
datanumber=n;
writexml("ren.csv");
}
String chx(String strx){
int p1=strx.indexOf("(作");
int p2=strx.indexOf(")",p1);
String sx1="";
if(p1>-1)sx1=strx.substring(p1,p2+1);
String sx2="";
if(p1>-1)sx2=strx.substring(p1+2,p2);
strx=strx.replace(sx1,sx2);
p1=strx.indexOf("(脚本");
p2=strx.indexOf(")",p1);
sx1="";
if(p1>-1)sx1=strx.substring(p1,p2+1);
sx2="";
if(p1>-1)sx2=strx.substring(p1+2,p2);
strx=strx.replace(sx1,sx2);
p1=strx.indexOf("(構成");
p2=strx.indexOf(")",p1);
sx1="";
if(p1>-1)sx1=strx.substring(p1,p2+1);
sx2="";
if(p1>-1)sx2=strx.substring(p1+2,p2);
strx=strx.replace(sx1,sx2);
p1=strx.indexOf("(シリーズ構成");
p2=strx.indexOf(")",p1);
sx1="";
if(p1>-1)sx1=strx.substring(p1,p2+1);
sx2="";
if(p1>-1)sx2=strx.substring(p1+2,p2);
strx=strx.replace(sx1,sx2);
return strx;
}
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("入出力エラーです。"); }
}
String clean_str(String str){
int kk;
String sp=str;
for(kk=1;kk<10;kk++){
sp=fresh(sp);
}
return sp;
}
String fresh(String strstr){
strstr=""+strstr;
int p1=strstr.indexOf("<");
int p2=-1;
if(p1>-1)p2=strstr.indexOf(">",p1);
String k="";
if(p2>-1)k=strstr.substring(p1,p2)+">";
String strxp=strstr.replace(k,"");
return strxp;
}
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;
}
}
最終更新:2017年12月13日 13:05