fastercsv

How do I robustly parse malformed CSV?

落爺英雄遲暮 提交于 2019-11-27 01:26:42
问题 I'm processing data from government sources (FEC, state voter databases, etc). It's inconsistently malformed, which breaks my CSV parser in all sorts of delightful ways. It's externally sourced and authoritative. I must parse it, and I cannot have it re-input, validated on input, or the like. It is what it is; I don't control the input. Properties: Fields contain malformed UTF-8 (e.g. Foo \xAB bar ) The first field of a line specifies the record type from a known set. Knowing the record type,

What is Ruby 1.9 standard CSV library?

谁说胖子不能爱 提交于 2019-11-26 13:50:09
问题 When I try the FasterCSV gem on my application I get this error: Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus support for Ruby 1.9's m17n encoding engine. By the way, I'm using Rails 3, Ruby 1.9.2, and Rubygems 1.4. Can someone explain to me please how to use the standard CSV library for Ruby 1.9. I don't have any idea at all because I'm very new to Rails. 回答1: Ruby 1.9 has adopted FasterCSV as its built-in CSV library. However, it's in the standard library rather