package test;
import java.io.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class pro {
int s,datanumber;
String[] data=new String[500000];
String[] tag=new String[500000];
String[] subdata=new String[500000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
readx("k.csv");
int tx=0;
for(s=1;s<datanumber+1;s++){
data[s]=change(data[s]);
data[s]=data[s].replace("\"","");
String y1=data[s].substring(0,2);
String m1=data[s].substring(2,4);
String[] x=data[s].split(",");
if(x.length==2) System.out.println(y1+","+m1+","+x[1]+","+"△");
if(x.length>2) System.out.println(y1+","+m1+","+x[1]+","+numx(x[2]));
}
datanumber=tx;
writexml("ren.txt");
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
String change(String str){
int n;
for(n=1;n<11;n++){
str=rev(str);
}
str=str.replace(" ","");
return str;
}
String rev(String str){
if(str==null)str="";
int p1=str.indexOf("<");
int p2=str.indexOf(">",p1);
String strx="";
if(p2>-1)strx=str.substring(p1,p2+1);
str=str.replace(strx,"");
return str;
}
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("入出力エラーです。"); }
}
void rev_csv(){
int s;
int[] point=new int[6000];
int[] delta=new int[6000];
String[] subdata=new String[6000];
for(s=1;s<datanumber+1;s++){
int c1=0;
int p1=data[s].indexOf("\"");
if(p1>-1)c1=1;
while(p1>-1){
p1=data[s].indexOf("\"",p1+1);
if(p1>-1)c1=c1+1;
}
point[s]=c1;
}
int n1;
n1=0;
int sx=1;
for(s=1;s<datanumber+1;s++){
n1=n1+point[s];
int n2=n1/2;
delta[s]=sx;
if(n1==2*n2)sx=sx+1;
if(n1==2*n2)n1=0;
}
int number=sx-1;
for(s=1;s<number+1;s++){
String str="";
for(sx=1;sx<datanumber+1;sx++){
if(delta[sx]==s)str=str+"△"+data[sx];
}
subdata[s]=str;
}
datanumber=number;
for(s=1;s<datanumber+1;s++){
data[s]=subdata[s];
}
}
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月19日 10:14