Skip to content

Instantly share code, notes, and snippets.

@keiso
Created September 18, 2012 17:24
Show Gist options
  • Save keiso/3744444 to your computer and use it in GitHub Desktop.
Save keiso/3744444 to your computer and use it in GitHub Desktop.
Googleドキュメントで集計したデータをIllustratorで読み込む為の加工用スクリプト
#!/usr/bin/perl
# 使い方
# 1)このスクリプトとGoogleドキュメントから書き出したcsvファイルを同一階層に置きます。
# (以下のスクリプトではフタッフアンケートの結果ファイル名を"stuff.csv"としています。)
# 2)Terminalでスクリプトを置いたディレクトリーに移動(cd)し、以下のコマンドを実行
# perl ./survey.pl > export.xml
# 補足)Terminalで指定のディレクトリーに移動する方法
# Terminalで"cd "とタイプしておき、
# Finderから移動したいフォルダーをTerminalのウインドウへドロップし、エンターキーを入力。
# 例) cd /Users/hogehoge/Documents/foo/bar/
print <<__HEAD__;
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd" [<!ENTITY ns_graphs "http://ns.adobe.com/Graphs/1.0/"><!ENTITY ns_vars "http://ns.adobe.com/Variables/1.0/"><!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/"><!ENTITY ns_custom "http://ns.adobe.com/GenericCustomNamespace/1.0/"><!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/"><!ENTITY ns_extend "http://ns.adobe.com/Extensibility/1.0/">]>
<svg>
<variableSets xmlns="http://ns.adobe.com/Variables/1.0/">
<variableSet varSetName="binding1" locked="none">
<variables>
<variable varName="name" trait="textcontent" category="http://ns.adobe.com/Flows/1.0/"/>
<variable varName="option" trait="textcontent" category="http://ns.adobe.com/Flows/1.0/"/>
<variable varName="section" trait="textcontent" category="http://ns.adobe.com/Flows/1.0/"/>
<variable varName="ug" trait="textcontent" category="http://ns.adobe.com/Flows/1.0/"/>
</variables>
<v:sampleDataSets xmlns="&ns_custom;" xmlns:v="&ns_vars;">
__HEAD__
if(open(FH,"stuff.csv")){
$count =0;
while(<FH>){
if($_ =~ m/^(\S+\s\d+:\d+:\d+),(.*),(.*),(.*),(.*),(.*),(\S*),(\S*),(\S*),(\S*)/){
local($timestamp,$name,$option,$section,$ug)=($1,$2,$3,$4,$5);
print <<__BEGIN__;
<v:sampleDataSet dataSetName="$count:$name">
__BEGIN__
# print $timestamp,"\n";
print "\t<name><p>",$name,"</p></name>\n";
print "\t<option><p>",$option,"</p></option>\n";
print "\t<section><p>",$section,"</p></section>\n";
print "\t<ug><p>",$ug,"</p></ug>\n\n";
$count++;
print <<__END__;
</v:sampleDataSet>
__END__
}
}
}
print <<__FOOT__;
</v:sampleDataSets>
</variableSet>
</variableSets>
</svg>
__FOOT__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment