Created
June 8, 2020 03:10
-
-
Save mamemomonga/b5002c7e96db46803d954c928b65b9f8 to your computer and use it in GitHub Desktop.
先頭がフィールドの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/perl | |
# 先頭がフィールドのTSVデータを読みやすい形に変換する | |
# 以下のようなTSVデータをKey:Valueの表示に変換する。 | |
# | |
# field1 field2 field3 | |
# data1 data2 data3 | |
# data1 data2 data3 | |
# | |
# 使い方 | |
# pbpaste | ./tsv-convert.pl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
my @data=<>; | |
my @fields=split(/\t/,shift @data); | |
foreach my $d (@data) { | |
my @lines=split(/\t/,$d); | |
for(my $i=0;$i<$#fields;$i++) { | |
printf("%20s: %s\n",$fields[$i], $lines[$i]); | |
} | |
say "-------------------------------------------------"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment