アットウィキロゴ

あだもすて

package city2;
 
import java.io.BufferedReader;
import java.io.BufferedWriter;
import tool.*; 
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
 
public class pro {
 
    int s,datanumber;
String[] data=new String[40000];
String[][] datax=new String[300][50];
  String[] name=new String[40000];
String[] credit=new String[40000];
 String[] code=new String[5000];
String[] year=new String[5000];
 String[] r=new String[5000];
 
 String[] imx=new String[60];
 int number;
 int delta;
 
 public static void main(String[] args) {
       pro t=new pro();
    }
    pro(){
 
 
        city250 sub=new city250();
        sub.makedata();
        name=sub.name;
        code=sub.code;
 number=sub.number;
 
 
 
        readx("data.csv");
 
 
        String[] y=data[1].split(",");
 
        for(s=1;s<y.length;s++){
           credit[s]=y[s];
            System.out.println(y[s]);
        }
 
        delta=y.length-1;
 
         for(s=2;s<datanumber+1;s++){
        String[] x=data[s].split(",");
        int sx;
        int sxs=0;
 
 
        for(sx=1;sx<number+1;sx++){
        if(code[sx].equals(x[0]))sxs=sx;    
        }
        for(sx=1;sx<x.length;sx++){
        datax[sxs][sx]=x[sx];
        }
 
 
         }
 
 
         writexml("ren.txt");
 
 
 
    }
 
  void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
 
 
pw.print("都市"); 
pw.print(","); 
pw.print("code");  
for(sx=1;sx<delta+1;sx++){
pw.print(",");
pw.print(credit[sx]); 
}
pw.println("");
for(s=1;s<number+1;s++){   
pw.print(name[s]); 
pw.print(","); 
pw.print(code[s]);  
for(sx=1;sx<delta+1;sx++){
pw.print(",");
pw.print(datax[s][sx]); 
}
pw.println("");
}
 
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
      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 city2;
 
import tool.*;
 
 
public class city250 {
 
  int s,datanumber;
String[] data=new String[5000];
 String[] code=new String[5000];
 String[][] namex=new String[50][50];
String[] name=new String[5000];
String[] year=new String[5000];
 String[] r=new String[5000];
 
 int number;
 
void makedata(){
 
    	 String str1="%20";
 String id="13oY_ATNC7diJaU1KYs05JGgBNBUrNjn1qzKsMKL6";
 
 
       String urlx="https://www.googleapis.com/fusiontables/v1/query?sql=SELECT";
       urlx=urlx+str1+"*"+str1+"FROM"+str1+id;
       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[] y=x[s].split(",");
 for(sx=0;sx<y.length;sx++){
 if(sx==0)name[s+1]=cg(y[sx]);
 if(sx==1)code[s+1]=cg(y[sx]);
 
 } 
 }
 
 
 
 
 
 number=x.length;
 
 for(s=1;s<number+1;s++){
 if(code[s].length()==4)code[s]="0"+code[s];    
 }
 
}
String cg(String c){
 
        int p1=c.indexOf("\"");
        int p2=c.indexOf("\"",p1+1);
        c=c.substring(p1+1,p2);
        return c;
    }
 
 
 
}
 
最終更新:2016年09月11日 10:06