Project

General

Profile

Actions

Bug #8784

closed

CSV - Empty fields are discarded when col_sep is a space

Added by grim7reaper (Sylvain Laperche) over 10 years ago. Updated about 6 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
Backport:
[ruby-core:56609]

Description

When using space as column delimiter, empty fields are discarded.
With other delimiters, like comma, empty fields are correctly retrieved.

The following code reproduces the problem:


#!/usr/bin/env ruby

require 'csv'

print(CSV.parse('2009,2,3,8,0,,30.1,,'))
puts
print(CSV.parse('2009 2 3 8 0 30.1 ', col_sep: ' '))
puts


Expected output
[["2009", "2", "3", "8", "0", nil, "30.1", nil, nil]]
[["2009", "2", "3", "8", "0", nil, "30.1", nil, nil]]

Current output
[["2009", "2", "3", "8", "0", nil, "30.1", nil, nil]]
[["2009", "2", "3", "8", "0", "30.1", nil]]


Files

bug_csv_col_sep.rb (142 Bytes) bug_csv_col_sep.rb grim7reaper (Sylvain Laperche), 02/08/2014 05:46 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0