Created
September 20, 2012 09:01
-
-
Save soh-i/3754778 to your computer and use it in GitHub Desktop.
Numbers.appの変なCSVをまともなTSVにエクスポートする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl -w | |
use strict; | |
# Convert CSV file that exported by Apple Numbers.app to TSV | |
my $file = shift || die; | |
open my $fh, '<', $file || die; | |
while ( my $entry = <$fh> ) { | |
#たくさん","ができるので消した. | |
if ( $entry =~ s/,{7}//g ) { | |
#なんか行頭にも","がくっついたのと最初行の"#"も消した | |
if ( $entry =~ s/^\,{1}|^\#\,//g ) { | |
# to tsv | |
if ( $entry =~ s/\,/\t/g ) { | |
print $entry; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment