package kand;
import java.io.*;
import tool.*;
public class pro {
int s,datanumber;
String[] data=new String[50000];
String[] name=new String[50000];
String[] geo=new String[50000];
String[] code=new String[50000];
String[] adr=new String[50000];
String[] lon=new String[50000];
String[] lat=new String[50000];
String[][] point=new String[50000][40];
int lastyear=29;
public static void main(String[] args) {
pro te=new pro();
}
pro(){
int sx;
readx("ten.txt");
for(s=1;s<datanumber+1;s++){
data[s]=data[s].replace(" ","");
catchword sub=new catchword();
geo[s]=sub.makedata(data[s],"geo");
name[s]=sub.makedata(data[s],"city");
code[s]=sub.makedata(data[s],"code");
adr[s]=sub.makedata(data[s],"adr");
for(sx=3;sx<lastyear+9;sx++){
String y1=""+(1980+sx);
point[s][sx]=sub.makedata(data[s],y1);
}
}
for(s=1;s<datanumber+1;s++){
int p1=geo[s].indexOf(".");
p1=geo[s].indexOf(".",p1+1);
lon[s]=geo[s].substring(0,p1-3);
lat[s]=geo[s].substring(p1-3,geo[s].length());
}
writecsv("del.csv");
}
void writecsv(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(s=1;s<datanumber+1;s++){
pw.print(name[s]);
pw.print(",");
pw.print(adr[s]);
pw.print(",");
pw.print(code[s]);
pw.print(",");
pw.print(lat[s]);
pw.print(",");
pw.print(lon[s]);
for(sx=3;sx<lastyear+9;sx++){
pw.print(",");
pw.print(point[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;
}
}
最終更新:2017年04月24日 06:36