package yati;
import tool.*;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class pro {
String[] year=new String[500];
String[] month=new String[500];
String[] day=new String[500];
int number;
int s,datanumber;
String[] data=new String[50000];
String[] name=new String[50000];
String[] code=new String[50000];
String[] yy=new String[50000];
public static void main(String[] args) {
pro te=new pro();
}
pro(){
readx("a.csv");
for(s=2;s<datanumber+1;s++){
String[] x=data[s].split(",");
name[s]=x[1];
code[s]="";
yy[s]=x[5];
if(x.length>6)code[s]=x[6];
}
int tr;
for(tr=30;tr<datanumber+1;tr++){
number=0;
if(code[tr].length()>0){
search sub=new search();
sub.makedata(code[tr]);
year=sub.year;
month=sub.month;
number=sub.number;
}
int s;
for(s=1;s<number+1;s++){
System.out.println(name[tr]+","+yy[tr]+"年,"+year[number-s+1]+"年"+month[number-s+1]+"月");
}
if(number<1)System.out.println(name[tr]+","+yy[tr]+"年,");
}
}
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;
}
}
package yati;
import tool.*;
public class search {
int s,datanumber;
String[] data=new String[5000];
String[] codex=new String[5000];
String[] code=new String[5000];
String[] name=new String[5000];
String[] y=new String[500];
String[] m=new String[500];
String[] d=new String[500];
String[] a=new String[500];
String[] namex=new String[5000];
String[] year=new String[500];
String[] month=new String[500];
String[] day=new String[500];
int number;
void makedata(String cc){
String str1="%20";
String id="1b1A3hL0UbFGjEt_TursiNcG56ZB8hr9ifm0RzF3E";
String urlx="https://www.googleapis.com/fusiontables/v1/query?sql=SELECT";
urlx=urlx+str1+"*"+str1+"FROM"+str1+id+str1+"where"+str1+"code="+cc;
urlx=urlx+"&key=AIzaSyAH0WCAXRIdHdbI-6bnMSN4kVDDZZmGyqY";
getdata sub=new getdata();
sub.makedata(urlx,"UTF-8");
data=sub.data;
datanumber=sub.datanumber;
String str="";
for(s=1;s<datanumber+1;s++){
str=str+data[s];
}
int p1=str.indexOf("rows");
p1=str.indexOf(":",p1);
str=str.substring(p1,str.length());
int sx;
int tx=0;
String[] x=str.split("],");
for(s=0;s<x.length;s++){
String[] y1=x[s].split(",");
y[s]="";
m[s]="";
d[s]="";
for(sx=0;sx<y1.length;sx++){
if(sx==0)y[s]=y1[sx];
if(sx==1)m[s]=y1[sx];
if(sx==2)d[s]=y1[sx];
}
}
sx=0;
for(s=0;s<x.length;s++){
if(y[s].indexOf("\"")>-1)sx=sx+1;
if(y[s].indexOf("\"")>-1)year[sx]=y[s];
if(y[s].indexOf("\"")>-1)month[sx]=m[s];
if(y[s].indexOf("\"")>-1)day[sx]=d[s];
}
number=sx;
for(s=1;s<number+1;s++){
int p2;
p1=year[s].indexOf("\"");
p2=year[s].indexOf("\"",p1+1);
year[s]=year[s].substring(p1+1,p2);
p1=month[s].indexOf("\"");
p2=month[s].indexOf("\"",p1+1);
month[s]=month[s].substring(p1+1,p2);
p1=day[s].indexOf("\"");
p2=day[s].indexOf("\"",p1+1);
day[s]=day[s].substring(p1+1,p2);
}
int n1=0;
if(number>0)n1=numx(year[1]);
if(n1<1800)number=0;
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
}
最終更新:2016年09月02日 02:15