var namex=new Array();
function myFunction() {
id="1dukQw_BbNAVT9Nd-gD8oL3YAtngY1m0s3Lp4NK39xcQ";
ex = SpreadsheetApp.openById(id);
var number = ex.getNumSheets();
Logger.log(number);
for(s=0;s<number;s++){
var shx = ex.getSheets()[s];
se=shx.getName();
namex[s+1]=se;
}
for(tr=1;tr<number+1;tr++){
var sheet=ex.getSheetByName(namex[tr]);
delta=sheet.getLastRow();
var v=sheet.getRange(1,1,delta,100).getValues();
fastline=0;
indexline=0;
for(s=1;s<10;s++){
for(sx=1;sx<4;sx++){
h=0;
str=""+v[s][sx];
if(str.indexOf("海")>-1)h=h+1;
if(str.indexOf("道")>-1)h=h+1;
if(h==2)fastline=s;
if(h==2)indexline=sx;
}}
Logger.log(indexline);
Logger.log(fastline);
lastline=0;
for(s=fastline;s<delta;s++){
h=0;
str=""+v[s][indexline];
if(str.indexOf("沖")>-1)h=h+1;
if(str.indexOf("縄")>-1)h=h+1;
if(h==2)lastline=s;
}
Logger.log(lastline);
creditline=0;
creditx=0;
for(s=1;s<fastline;s++){
for(sx=indexline;sx<indexline+10;sx++){
h=0;
str=""+v[s][sx];
if(str.indexOf("産")>-1)h=h+1;
if(str.indexOf("業")>-1)h=h+1;
if(creditline==0)h=h+1;
if(h==3)creditline=s;
if(h==3)creditx=sx;
}}
var credit=new Array();
Logger.log(creditline);
Logger.log(creditx);
credity=0;
for(sx=creditx;sx<98;sx++){
str="";
for(s=creditline;s<fastline;s++){
h=0;
str=str+v[s][sx];
}
credit[sx]=str;
if(str.length>0)credity=sx;
}
var bus=new Array();
bus[3]="食料品";
bus[4]="繊維";
bus[5]="パルプ紙";
bus[6]="化学";
bus[7]="石油石炭製品";
bus[8]="窯業土石製品";
bus[9]="一次金属";
bus[10]="金属製品";
bus[11]="一般機械";
bus[12]="電気機械";
bus[13]="輸送用機械";
bus[14]="精密機械";
bus[15]="その他の製造業";
bus[16]="建設業";
bus[17]="電気ガス水道業";
bus[18]="卸売小売業";
bus[19]="金融保険業";
bus[20]="不動産業";
bus[21]="運輸業";
bus[22]="情報通信業";
bus[23]="サービス業";
bus[24]="政府サービス生産者";
bus[25]="対家計民間非営利サービス生産者";
bus[1]="農林水産業";
bus[2]="鉱業";
var point=new Array();
for(s=1;s<27;s++){
point[s]=0;
}
for(s=creditx;s<credity+1;s++){
h=0;
if(credit[s].indexOf("農")>-1)h=h+1;
if(credit[s].indexOf("水")>-1)h=h+1;
if(h==2)point[1]=s;
h=0;
if(credit[s].indexOf("鉱")>-1)h=h+1;
if(credit[s].indexOf("業")>-1)h=h+1;
if(h==2)point[2]=s;
h=0;
if(credit[s].indexOf("食")>-1)h=h+1;
if(credit[s].indexOf("料")>-1)h=h+1;
if(h==2)point[3]=s;
h=0;
if(credit[s].indexOf("繊")>-1)h=h+1;
if(credit[s].indexOf("維")>-1)h=h+1;
if(h==2)point[4]=s;
h=0;
if(credit[s].indexOf("紙")>-1)h=h+1;
if(credit[s].indexOf("紙")>-1)h=h+1;
if(h==2)point[5]=s;
h=0;
if(credit[s].indexOf("化")>-1)h=h+1;
if(credit[s].indexOf("学")>-1)h=h+1;
if(h==2)point[6]=s;
h=0;
if(credit[s].indexOf("油")>-1)h=h+1;
if(credit[s].indexOf("炭")>-1)h=h+1;
if(h==2)point[7]=s;
h=0;
if(credit[s].indexOf("窯")>-1)h=h+1;
if(credit[s].indexOf("土")>-1)h=h+1;
if(h==2)point[8]=s;
h=0;
if(credit[s].indexOf("鉄")>-1)h=h+1;
if(credit[s].indexOf("鋼")>-1)h=h+1;
if(h==2)point[9]=s;
h=0;
if(credit[s].indexOf("金")>-1)h=h+1;
if(credit[s].indexOf("製")>-1)h=h+1;
if(h==2)point[10]=s;
h=0;
if(credit[s].indexOf("般")>-1)h=h+1;
if(credit[s].indexOf("械")>-1)h=h+1;
if(h==2)point[11]=s;
h=0;
if(credit[s].indexOf("電")>-1)h=h+1;
if(credit[s].indexOf("械")>-1)h=h+1;
if(h==2)point[12]=s;
h=0;
if(credit[s].indexOf("輸")>-1)h=h+1;
if(credit[s].indexOf("械")>-1)h=h+1;
if(h==2)point[13]=s;
h=0;
if(credit[s].indexOf("精")>-1)h=h+1;
if(credit[s].indexOf("密")>-1)h=h+1;
if(h==2)point[14]=s;
h=0;
if(credit[s].indexOf("そ")>-1)h=h+1;
if(credit[s].indexOf("製")>-1)h=h+1;
if(h==2)point[15]=s;
h=0;
if(credit[s].indexOf("建")>-1)h=h+1;
if(credit[s].indexOf("設")>-1)h=h+1;
if(h==2)point[16]=s;
h=0;
if(credit[s].indexOf("電")>-1)h=h+1;
if(credit[s].indexOf("ガ")>-1)h=h+1;
if(h==2)point[17]=s;
h=0;
if(credit[s].indexOf("卸")>-1)h=h+1;
if(credit[s].indexOf("小")>-1)h=h+1;
if(h==2)point[18]=s;
h=0;
if(credit[s].indexOf("金")>-1)h=h+1;
if(credit[s].indexOf("保")>-1)h=h+1;
if(h==2)point[19]=s;
h=0;
if(credit[s].indexOf("動")>-1)h=h+1;
if(credit[s].indexOf("不")>-1)h=h+1;
if(h==2)point[20]=s;
h=0;
if(credit[s].indexOf("輸")>-1)h=h+1;
if(credit[s].indexOf("運")>-1)h=h+1;
if(h==2)point[21]=s;
h=0;
if(credit[s].indexOf("情")>-1)h=h+1;
if(credit[s].indexOf("通")>-1)h=h+1;
if(h==2)point[22]=s;
h=0;
if(credit[s].indexOf("サ")>-1)h=h+1;
if(credit[s].indexOf("情")<0)h=h+1;
if(point[23]==0)h=h+1;
if(h==3)point[23]=s;
h=0;
if(credit[s].indexOf("政")>-1)h=h+1;
if(credit[s].indexOf("府")>-1)h=h+1;
if(h==2)point[24]=s;
h=0;
if(credit[s].indexOf("非")>-1)h=h+1;
if(credit[s].indexOf("営")>-1)h=h+1;
if(h==2)point[25]=s;
h=0;
if(credit[s].indexOf("非")>-1)h=h+1;
if(credit[s].indexOf("鉄")>-1)h=h+1;
if(h==2)point[26]=s;
Logger.log(credit[s]);
}
var vs=new Array();
for(s=0;s<48;s++){
vs[s]=new Array();
}
for(s=1;s<48;s++){
for(sx=1;sx<26;sx++){
vs[s][sx]=0;
}}
for(sx=1;sx<26;sx++){
vs[0][sx]=bus[sx];
}
for(s=1;s<48;s++){
vs[s][0]=v[fastline+s-1][indexline];
for(sx=1;sx<26;sx++){
s1=point[sx];
vs[s][sx]=v[fastline+s-1][s1]/1;
}
s2=point[26];
vs[s][9]=vs[s][9]+v[fastline+s-1][s2]/1;
}
id3="1hZl_VqPFSvkbfvopaHy_mMTJiu0lZI8oGedMyV45d04";
var ex3 = SpreadsheetApp.openById(id3);
ex3.insertSheet(namex[tr]);
var sh3 = ex3.getSheetByName(namex[tr]);
sh3.getRange(1,1,48,26).setValues(vs);
}
}
最終更新:2017年04月20日 19:27