W-ZERO3のアドレス帳をFOMAのデータリンクソフト用に変換
Table of Contents
概要
- アドレス帳CSVコンバータでCSVに書き出した[W-ZERO3]]のアドレス帳を、FOMA [N701iにデータリンクソフトで読み込める形式に変換する。
ソースコード
$fin = "W03.csv";
$fout = "FOMA.csv";
# メモリ番号の最初の値
$MemoryNo = 10;
@TelKeys =(
"BusinessTelephoneNumber", "BusinessFaxNumber", "CompanyTelephoneNumber",
"MobileTelephoneNumber", "HomeTelephoneNumber", "Home2TelephoneNumber",
);
@EMailKeys = (
"Email1Address", "Email2Address", "Email3Address",
);
%Icon =(
"BusinessTelephoneNumber" => 3, "BusinessFaxNumber" => 4, "CompanyTelephoneNumber" => 3,
"MobileTelephoneNumber" => 1, "HomeTelephoneNumber" => 2, "Home2TelephoneNumber" => 2,
"Email1Address" => 24, "Email2Address" => 24, "Email3Address" => 24,
);
open( IN, $fin ) || die( "can't open'".$fin."'.\n" );
open( OUT, ">".$fout ) || die( "can't open'".$fout."'.\n" );
$line = <IN>;
chop( $line );
@fields = split( ",", $line );
@addr_in = <IN>;
close( IN );
chop( @addr_in );
for( $i=0; $i<@addr_in; ++$i ){
@addr_tmp = split( ",", $addr_in[ $i ] );
%addr_out = ();
for( $j=0; $j<@fields; ++$j ){
if ( $addr_tmp[ $j ] =~ /^"(.*)"$/ ){
$addr_tmp[ $j ] = $1;
}
$addr_out{ $fields[ $j ] } = $addr_tmp[ $j ];
}
$Name = $addr_out{ "FileAs" };
$Yomi = $addr_out{ "YomiLastName" }.$addr_out{ "YomiFirstName" };
$Group = "0";
$Secret = "0";
$PostalCode = $addr_out{ "BusinessAddressPostalCode" };
$Addr = $addr_out{ "BusinessAddressState" }.$addr_out{ "BusinessAddressCity" }.$addr_out{ "BusinessAddressStreet" };
$Memo = $addr_out{ "CompanyName" };
if ( $addr_out{ "Birthday" } ne "" ){
$Birthday = "19".$addr_out{ "Birthday" };
}
$step = 0;
foreach $telkey ( @TelKeys ){
$addr_out{ $telkey } =~ tr/-() //d;
if ( $addr_out{ $telkey } ne "" ){
printf OUT (
"\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n",
$MemoryNo+$i+$step, $Name, $Yomi, $addr_out{ $telkey }, $Group, $Icon{ $telkey },
$Secret, "", $PostalCode, $Addr, $Memo, $Birthday
);
$step += 700;
}
}
$step = 2800;
foreach $emailkey ( @EMailKeys ){
if ( $addr_out{ $emailkey } ne "" ){
printf OUT (
"\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n",
$MemoryNo+$i+$step, $Name, $Yomi, "", $Group, $Icon{ $emailkey },
$Secret, $addr_out{ $emailkey }, $PostalCode, $Addr, $Memo, $Birthday
);
$step += 700;
}
}
}
close( OUT );
# EOF
アイコン番号
固定電話 | |
---|---|
1 | 携帯電話 |
2 | 自宅電話 |
3 | 会社電話 |
4 | 会社FAX |
24 | 一般メール |
25 | 自宅メール |
26 | 会社メール |
27 | 携帯メール |