DEV Community

Dharshan Bharathuru
Dharshan Bharathuru

Posted on

2 2

Any difference in Ruby CSV library from 2.3.3/2.4.4 vs 2.5.1?

While migrating a small ruby app from ruby 2.3.3 to ruby 2.5.1, I am having problem parsing a mechanize text csv file with CSV library. Which works just fine with ruby 2.3.3 and 2.4.4.

csv_header = ["Rep Date", "Or No", "Qw Type", "Sett No", "Order Date", "AS Code", "ZCV", "Amount", "Qty", "BN Code", "AX Code", "User Id", "QW No", "QX Code", "WE No", "MN Code", "KL Name", "IO Id", "A AS", "DD Unit", "DD Amt", "DD Flag", "Remarks", "RRR", "KK Ref No", "TY Type", "SS Regn No", "SR Reg Date", "SU Code", "PPP", "QQQ DEC", "NM Flag", "DP Trans", "O Type"].freeze
converter = lambda { |field, _| field.strip rescue field }
response = agent.submit(form, button)

parsed = CSV.parse(response.body, col_sep: '|', write_headers: true, headers: csv_header, converters: [converter])


# in ruby 2.3.3
parsed.count # 1523

# in ruby 2.5.1
parsed.count # 0

# data in response body looks like bellow
"2018-12-05|8761|T3|9166|2018-12-03|1-R|1JF5|10000.0000|0|11|PBRANCH|88701|2030|489|2312051|4CUM|Kapoor ||41.3500|241.8380|10000.0000|Y||0.0000|66747|SP|3674|24/10/2018|||N|Y|P|NRM|\n2018-12-04|9525|T3|9166|2018-12-03|2-G|1JF5|1000.0000|0|11|BBRANCH|88701|21551|489|545481|VPA|Prasad P||41.3500|24.1840|1000.0000|Y||0.0000|78232|TP|6879|24/09/2018|||N|Y|P|NRM|\n2018-12-04.."

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay