テーブルの時間列に欠落しているコロンを追加する

テーブルの時間列に欠落しているコロンを追加する

次の表があります。

"Date","Time","Open","High","Low","Close","Volume"
06/28/2004,0931,37.49,37.50,37.45,37.46,1049200
06/28/2004,0932,37.48,37.50,37.45,37.48,450700
06/28/2004,0933,37.48,37.50,37.46,37.49,493700
06/28/2004,0934,37.49,37.50,37.47,37.47,756100
06/28/2004,0935,37.48,37.49,37.46,37.48,309000

残念ながら、時間列は数字にすぎず、:数字のペアの間に欠けています。テーブルの時刻が次のように正しく表示されるように変更するにはどうすればよいですか?

"Date","Time","Open","High","Low","Close","Volume"
06/28/2004,09:31,37.49,37.50,37.45,37.46,1049200
06/28/2004,09:32,37.48,37.50,37.45,37.48,450700
06/28/2004,09:33,37.48,37.50,37.46,37.49,493700
06/28/2004,09:34,37.49,37.50,37.47,37.47,756100
06/28/2004,09:35,37.48,37.49,37.46,37.48,309000

ベストアンサー1

awk -vFS="" -vOFS="" 'NR>1 {$13=$13":"}1' file

"Date","Time","Open","High","Low","Close","Volume"
06/28/2004,09:31,37.49,37.50,37.45,37.46,1049200
06/28/2004,09:32,37.48,37.50,37.45,37.48,450700
06/28/2004,09:33,37.48,37.50,37.46,37.49,493700
06/28/2004,09:34,37.49,37.50,37.47,37.47,756100
06/28/2004,09:35,37.48,37.49,37.46,37.48,309000

-vFS="" -vOFS=""入力フィールドと出力フィールドの区切り文字をnonに設定します。

NR>1最初の行の変更を防ぐために、2行目から変更が適用されることを意味します。

{$13=$13":"}文字列 13 の後にコロンを挿入します。

おすすめ記事