package actor;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.*;
public class Actor {
String[] data=new String[5000];
int s,datanumber,number;
String[] title=new String[5000];
String[] code=new String[5000];
String[] artist=new String[5000];
String[] subdata=new String[500000];
public static void main(String[] args) {
Actor t=new Actor();
}
Actor(){
readx("data.csv");
for(s=1;s<datanumber;s++){
String[] x=data[s+1].split(",");
title[s]=x[0];
code[s]=x[1];
}
int n=0;
number=datanumber;
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];
}
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];
}
int number_artist=sx;
System.out.println(number_artist);
for(s=1;s<number_artist+1;s++){
n=n+1;
subdata[n]=title[tr]+","+code[tr]+","+artist[s];
}
}
datanumber=n;
writexml("ren.csv");
}
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年07月21日 13:08