ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: kou@cozmixng.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90349] [Ruby trunk Bug#15388][Assigned] CSV parsing behaviour in > 2.5.0
Date: Fri, 07 Dec 2018 02:07:36 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-75460.20181207020735.17d729a50ad62686@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15388.20181206174709@ruby-lang.org

Issue #15388 has been updated by kou (Kouhei Sutou).

Status changed from Open to Assigned
Assignee set to kou (Kouhei Sutou)

Arguments validation may be better but we need more works for it. For example, we need to add similar logic to `CSV.read` for this case.

Anyone who wants to work on argument validation should send pull requests to https://github.com/ruby/csv .

----------------------------------------
Bug #15388: CSV parsing behaviour in > 2.5.0
https://bugs.ruby-lang.org/issues/15388#change-75460

* Author: dharshandj@gmail.com (Dharshan Bharathuru)
* Status: Assigned
* Priority: Normal
* Assignee: kou (Kouhei Sutou)
* Target version: 
* ruby -v: 2.5.1
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hi,

It seems like CSV library in 2.5.0 is not behaving as intended while parsing.

~~~ ruby
header = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q"]

csv_str = "10.4710|859.5170|9000.0000|Y||0.0000||NRM|0||||N|Y|P|NRM|\r\n11.4710|869.5170|9000.0000|Y||0.0000||NRM|0||||N|Y|P|NRM|\r\n"

CSV.parse(csv_str, col_sep: '|', write_headers: true, headers: header)[0]
# produces junk
# #<CSV::Row "A":"0" "B":nil "C":"NRM" "D":"0" "E":nil "F":nil "G":nil "H":"N" "I":"Y" "J":"P" "K":"NRM" "L":nil "M":nil "N":nil "O":nil "P":nil "Q":nil>

~~~

But without `write_headers` option it produces correct parsing.

~~~ ruby
CSV.parse(csv_str, col_sep: '|', headers: header)[0]

# #<CSV::Row "A":"10.4710" "B":"859.5170" "C":"9000.0000" "D":"Y" "E":nil "F":"0.0000" "G":nil "H":"NRM" "I":"0" "J":nil "K":nil "L":nil "M":"N" "N":"Y" "O":"P" "P":"NRM" "Q":nil>

~~~



 



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2018-12-07  2:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15388.20181206174709@ruby-lang.org>
2018-12-06 17:47 ` [ruby-core:90342] [Ruby trunk Bug#15388] CSV parsing behaviour in > 2.5.0 dharshandj
2018-12-07  0:02 ` [ruby-core:90343] " nobu
2018-12-07  0:31 ` [ruby-core:90344] " nobu
2018-12-07  0:49 ` [ruby-core:90345] " dharshandj
2018-12-07  1:44 ` [ruby-core:90347] " nobu
2018-12-07  1:59 ` [ruby-core:90348] " kou
2018-12-07  2:07 ` kou [this message]
2018-12-07  3:05 ` [ruby-core:90354] " dharshandj
2018-12-07  3:24 ` [ruby-core:90355] [Ruby trunk Bug#15388][Closed] " kou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-75460.20181207020735.17d729a50ad62686@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).