Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  File.readlines('a.csv').each do |l|
     puts l unless l =~ /^\s*$/ 
  end

output:

<snip 1000 rows>
825,2007-12-22,2007-12-28
825,2008-05-24,2008-05-30
852,2007-11-10,2008-02-29
863,2007-11-10,2008-03-31
881,2007-11-10,2008-03-04
889,2007-11-10,2008-03-14
890,2007-11-

$ ruby -pe 'next if $_ =~ /^\s*$/' < a.csv

output:

<snip 1000 rows>
825,2007-12-22,2007-12-28
825,2008-05-24,2008-05-30
852,2007-11-10,2008-02-29
863,2007-11-10,2008-03-31
881,2007-11-10,2008-03-04
889,2007-11-10,2008-03-14
890,2007-11-10,2008-03-14
890,2008-04-26,2008-05-02
<end of file>