package pp;
import tool.*;
import java.io.*;
public class pro {
String urlx;
String[] data=new String[500000];
String[] v=new String[500000];
String[][] credit=new String[10][5000];
int s,sx,datanumber,tx;
int[] px=new int[50];
int number;
int[] creditnumber=new int[50];
String[][] code=new String[10][5000];
String str;
int n,nx;
String id;
String[] value=new String[100000];
String[][] ac=new String[100000][6];
public static void main(String[] args) {
pro test=new pro();
}
pro(){
id="0003013703";
readfile sub=new readfile();
sub.makedata("index.txt","UTF-8");
data=sub.data;
datanumber=sub.datanumber;
for(s=2;s<datanumber+1;s++){
str=data[s];
String[] x=str.split(",");
n=Integer.parseInt(x[0]);
nx=Integer.parseInt(x[1]);
code[n][nx]=x[2];
credit[n][nx]=x[3];
creditnumber[n]=nx;
number=n;
}
s=4;
for(sx=1;sx<creditnumber[s]+1;sx++){
System.out.println(credit[s][sx]);
}
urlx="http://statdb.nstac.go.jp/api/1.0b/app/getStatsData?appId=aeec3b02995623cad42b80c80f73d176b7c77970";
urlx=urlx+"&statsDataId="+id+"&cdTime="+code[4][2];
gerdata sub3=new gerdata();
sub3.makedata(urlx);
data=sub3.data;
datanumber=sub3.datanumber;
sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("<VALUE")>-1)sx=sx+1;
if(data[s].indexOf("<VALUE")>-1)v[sx]=data[s];
}
datanumber=sx;
int p1,p2;
for(s=1;s<datanumber+1;s++){
str=v[s];
p1=str.indexOf(">");
p2=str.indexOf("</",p1);
str=str.substring(p1+1,p2);
value[s]=str;
}
String strx;
for(s=1;s<datanumber+1;s++){
str=v[s];
p1=0;
p2=0;
for(sx=1;sx<number+1;sx++){
p1=str.indexOf("=",p2);
p1=str.indexOf("\"",p1);
p2=str.indexOf("\"",p1+1);
strx=str.substring(p1+1,p2);
ac[s][sx]=strx;
}
}
writedata("ren.txt");
}
void writedata(String file){
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.println("a,b,c,t,v");
for(s=1;s<datanumber+1;s++){
for(sx=1;sx<number+1;sx++){
pw.print(ac[s][sx]);
pw.print(",");
}
pw.println(value[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
package pp;
import tool.*;
import java.io.*;
public class index {
String urlx;
String[] data=new String[50000];
String[][] credit=new String[10][5000];
int s,sx,datanumber,tx;
int[] px=new int[50];
int number;
int[] creditnumber=new int[50];
String[][] code=new String[10][5000];
void makedata(String id){
urlx="http://statdb.nstac.go.jp/api/1.0b/app/getMetaInfo?appId=aeec3b02995623cad42b80c80f73d176b7c77970";
urlx=urlx+"&statsDataId="+id;
getdata sub3=new getdata();
sub3.makedata(urlx,"UTF-8");
data=sub3.data;
datanumber=sub3.datanumber;
sx=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("<CLASS_OBJ id=")>-1)sx=sx+1;
if(data[s].indexOf("<CLASS_OBJ id=")>-1)px[sx]=s;
}
number=sx;
for(s=1;s<number;s++){
tx=0;
for(sx=px[s];sx<px[s+1];sx++){
if(data[sx].indexOf("<CLASS code")>-1)tx=tx+1;
if(data[sx].indexOf("<CLASS code")>-1)credit[s][tx]=data[sx];
}
creditnumber[s]=tx;
}
s=number;
tx=0;
for(sx=px[s];sx<datanumber;sx++){
if(data[sx].indexOf("<CLASS code")>-1)tx=tx+1;
if(data[sx].indexOf("<CLASS code")>-1)credit[s][tx]=data[sx];
}
creditnumber[s]=tx;
String str;
int p1,p2;
for(s=1;s<number+1;s++){
for(sx=1;sx<creditnumber[s]+1;sx++){
str=credit[s][sx];
p1=str.indexOf("code=");
p1=str.indexOf("\"",p1);
p2=str.indexOf("\"",p1+1);
str=str.substring(p1+1,p2);
code[s][sx]=str;
str=credit[s][sx];
p1=str.indexOf("name=");
p1=str.indexOf("\"",p1);
p2=str.indexOf("\"",p1+1);
credit[s][sx]=str.substring(p1+1,p2);
}
}
writeindex("index.txt");
}
void writeindex(String file){
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.println("s,sx,code,credit");
for(s=1;s<number+1;s++){
for(sx=1;sx<creditnumber[s]+1;sx++){
pw.print(s);
pw.print(",");
pw.print(sx);
pw.print(",");
pw.print(code[s][sx]);
pw.print(",");
pw.println(credit[s][sx]);
}
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
最終更新:2014年01月01日 23:44