ruby1.9 csv

    技术2025-04-12  43

    # I'm sure I'll miss something, but I'll try to mention most of the major # differences I am aware of, to help others quickly get up to speed: # # === CSV Parsing # # * This parser is m17n aware.  See CSV for full details. # * This library has a stricter parser and will throw MalformedCSVErrors on #   problematic data. # * This library has a less liberal idea of a line ending than CSV.  What you #   set as the <tt>:row_sep</tt> is law.  It can auto-detect your line endings #   though. # * The old library returned empty lines as <tt>[nil]</tt>.  This library calls #   them <tt>[]</tt>. # * This library has a much faster parser. # # === Interface # # * CSV now uses Hash-style parameters to set options. # * CSV no longer has generate_row() or parse_row(). # * The old CSV's Reader and Writer classes have been dropped. # * CSV::open() is now more like Ruby's open(). # * CSV objects now support most standard IO methods. # * CSV now has a new() method used to wrap objects like String and IO for #   reading and writing. # * CSV::generate() is different from the old method. # * CSV no longer supports partial reads.  It works line-by-line. # * CSV no longer allows the instance methods to override the separators for #   performance reasons.  They must be set in the constructor. # === To a File # #   CSV.open("path/to/file.csv", "wb") do |csv| #     csv << ["row", "of", "CSV", "data"] #     csv << ["another", "row"] #     # ... #   end
    最新回复(0)