質問するログイン新規登録

回答編集履歴

1

1列目の削除処理を追加

2016/05/22 08:06

投稿

katoy
katoy

スコア22328

answer CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  table = CSV.table(infile)
10
10
  table[:col3] = table[:col1]
11
+ table.by_col!.delete(:col1)
11
12
  File.write(outfile, table)
12
13
  ```
13
14
  実行結果
@@ -25,15 +26,15 @@
25
26
  $ ruby a.rb
26
27
 
27
28
  $ cat out.csv
29
+ col2,col3
30
+ 1,a
31
+ 2,b
32
+ 3,c
33
+ 4,d
34
+ 5,e
35
+ 6,f
36
+ 7,g
28
37
 
29
- col1,col2,col3
30
- a,1,a
31
- b,2,b
32
- c,3,c
33
- d,4,d
34
- e,5,e
35
- f,6,f
36
- g,7,g
37
38
  ```
38
39
 
39
40
  > ... CSVファイルの何行何列目をダイレクトに削除 ...