我有一個CSV文件,其中包含標題行和數據之前的註釋文本,我希望將其作爲散列讀入以供進一步操作。主鍵有散列將是兩個數據值的組合。我如何?Perl CSV來散列
- 搜索使用模式「索引」
- 將標題鑰匙
- 讀入文件的其餘部分的標題行。
例CSV
#
#
#
#
Description information of source of file.
index,label,bit,desc,mnemonic
6,370,11,three,THRE
9,240,23,four,FOR
11,120,n/a,five,FIV
例所需的哈希
('37011' => { 'index' => '6', 'label' => '370', 'bit' => '11', 'desc' => 'three', 'mnemonic' => 'THRE'}, '24023' => {'index' => '9', 'label' => '240', 'bit' => '23', 'desc' => 'four', 'mnemonic' => 'FOR'}, '120n/a' => {'index' => '11', 'label' => '120', 'bit' => 'n/a', 'desc' => 'five', 'mnemonic' => 'FIV'})
[Text :: CSV :: Simple](https://metacpan.org/pod/Text::CSV::Simple)使這更簡單。大師作品 – 2014-06-06 13:53:53