ruby-changes:63732
From: Burdette <ko1@a...>
Date: Tue, 24 Nov 2020 09:34:44 +0900 (JST)
Subject: [ruby-changes:63732] 3cfb63fcd8 (master): [ruby/csv] More on Recipes headers (#183)
https://git.ruby-lang.org/ruby.git/commit/?id=3cfb63fcd8 From 3cfb63fcd864e6114138a9ba4e972bd616034bc2 Mon Sep 17 00:00:00 2001 From: Burdette Lamar <BurdetteLamar@Y...> Date: Fri, 9 Oct 2020 17:36:03 -0500 Subject: [ruby/csv] More on Recipes headers (#183) https://github.com/ruby/csv/commit/d7ae3df801 diff --git a/doc/csv/recipes.rdoc b/doc/csv/recipes.rdoc index 5c1f745..a620dca 100644 --- a/doc/csv/recipes.rdoc +++ b/doc/csv/recipes.rdoc @@ -6,62 +6,62 @@ All code snippets on this page assume that the following has been executed: https://github.com/ruby/ruby/blob/trunk/doc/csv/recipes.rdoc#L6 === Contents - {Parsing: Source Formats}[#label-Parsing-3A+Source+Formats] - - {Parse from String}[#label-Parse+from+String] - - {Parse from String with Headers}[#label-Parse+from+String+with+Headers] - - {Parse from String Without Headers}[#label-Parse+from+String+Without+Headers] - - {Parse from File}[#label-Parse+from+File] - - {Parse from File with Headers}[#label-Parse+from+File+with+Headers] - - {Parse from File Without Headers}[#label-Parse+from+File+Without+Headers] - - {Parse from IO Stream}[#label-Parse+from+IO+Stream] - - {Parse from IO Stream with Headers}[#label-Parse+from+IO+Stream+with+Headers] - - {Parse from IO Stream Without Headers}[#label-Parse+from+IO+Stream+Without+Headers] + - {Parsing from a String}[#label-Parsing+from+a+String] + - {Recipe: Parse from String with Headers}[#label-Recipe-3A+Parse+from+String+with+Headers] + - {Recipe: Parse from String Without Headers}[#label-Recipe-3A+Parse+from+String+Without+Headers] + - {Parsing from a File}[#label-Parsing+from+a+File] + - {Recipe: Parse from File with Headers}[#label-Recipe-3A+Parse+from+File+with+Headers] + - {Recipe: Parse from File Without Headers}[#label-Recipe-3A+Parse+from+File+Without+Headers] + - {Parsing from an IO Stream}[#label-Parsing+from+an+IO+Stream] + - {Recipe: Parse from IO Stream with Headers}[#label-Recipe-3A+Parse+from+IO+Stream+with+Headers] + - {Recipe: Parse from IO Stream Without Headers}[#label-Recipe-3A+Parse+from+IO+Stream+Without+Headers] - {Parsing: Field Converters}[#label-Parsing-3A+Field+Converters] - - {Convert Fields to Objects}[#label-Convert+Fields+to+Objects] - - {Convert Fields to Integers}[#label-Convert+Fields+to+Integers] - - {Convert Fields to Floats}[#label-Convert+Fields+to+Floats] - - {Convert Fields to Numerics}[#label-Convert+Fields+to+Numerics] - - {Convert Fields to Dates}[#label-Convert+Fields+to+Dates] - - {Convert Fields to DateTimes}[#label-Convert+Fields+to+DateTimes] - - {Convert Assorted Fields to Objects}[#label-Convert+Assorted+Fields+to+Objects] - - {Convert Fields to Other Objects}[#label-Convert+Fields+to+Other+Objects] - - {Filter Field Strings}[#label-Filter+Field+Strings] - - {Register Field Converters}[#label-Register+Field+Converters] - - {Use Multiple Field Converters}[#label-Use+Multiple+Field+Converters] - - {Specify Multiple Field Converters in Option :converters}[#label-Specify+Multiple+Field+Converters+in+Option+-3Aconverters] - - {Specify Multiple Field Converters in a Custom Converter List}[#label-Specify+Multiple+Field+Converters+in+a+Custom+Converter+List] + - {Converting Fields to Objects}[#label-Converting+Fields+to+Objects] + - {Recipe: Convert Fields to Integers}[#label-Recipe-3A+Convert+Fields+to+Integers] + - {Recipe: Convert Fields to Floats}[#label-Recipe-3A+Convert+Fields+to+Floats] + - {Recipe: Convert Fields to Numerics}[#label-Recipe-3A+Convert+Fields+to+Numerics] + - {Recipe: Convert Fields to Dates}[#label-Recipe-3A+Convert+Fields+to+Dates] + - {Recipe: Convert Fields to DateTimes}[#label-Recipe-3A+Convert+Fields+to+DateTimes] + - {Recipe: Convert Assorted Fields to Objects}[#label-Recipe-3A+Convert+Assorted+Fields+to+Objects] + - {Recipe: Convert Fields to Other Objects}[#label-Recipe-3A+Convert+Fields+to+Other+Objects] + - {Recipe: Filter Field Strings}[#label-Recipe-3A+Filter+Field+Strings] + - {Recipe: Register Field Converters}[#label-Recipe-3A+Register+Field+Converters] + - {Using Multiple Field Converters}[#label-Using+Multiple+Field+Converters] + - {Recipe: Specify Multiple Field Converters in Option :converters}[#label-Recipe-3A+Specify+Multiple+Field+Converters+in+Option+-3Aconverters] + - {Recipe: Specify Multiple Field Converters in a Custom Converter List}[#label-Recipe-3A+Specify+Multiple+Field+Converters+in+a+Custom+Converter+List] - {Generating: Output Formats}[#label-Generating-3A+Output+Formats] - - {Generate to String}[#label-Generate+to+String] - - {Generate to String with Headers}[#label-Generate+to+String+with+Headers] - - {Generate to String Without Headers}[#label-Generate+to+String+Without+Headers] - - {Generate to File}[#label-Generate+to+File] - - {Generate to File with Headers}[#label-Generate+to+File+with+Headers] - - {Generate to File Without Headers}[#label-Generate+to+File+Without+Headers] - - {Generate to IO Stream}[#label-Generate+to+IO+Stream] - - {Generate to IO Stream with Headers}[#label-Generate+to+IO+Stream+with+Headers] - - {Generate to IO Stream Without Headers}[#label-Generate+to+IO+Stream+Without+Headers] + - {Generating to a String}[#label-Generating+to+a+String] + - {Recipe: Generate to String with Headers}[#label-Recipe-3A+Generate+to+String+with+Headers] + - {Recipe: Generate to String Without Headers}[#label-Recipe-3A+Generate+to+String+Without+Headers] + - {Generating to a File}[#label-Generating+to+a+File] + - {Recipe: Generate to File with Headers}[#label-Recipe-3A+Generate+to+File+with+Headers] + - {Recipe: Generate to File Without Headers}[#label-Recipe-3A+Generate+to+File+Without+Headers] + - {Generating to IO an Stream}[#label-Generating+to+an+IO+Stream] + - {Recipe: Generate to IO Stream with Headers}[#label-Recipe-3A+Generate+to+IO+Stream+with+Headers] + - {Recipe: Generate to IO Stream Without Headers}[#label-Recipe-3A+Generate+to+IO+Stream+Without+Headers] - {Filtering: Source and Output Formats}[#label-Filtering-3A+Source+and+Output+Formats] - - {Filter String to String}[#label-Filter+String+to+String] - - {Filter String to String with Headers}[#label-Filter+String+to+String+with+Headers] - - {Filter String to String Without Headers}[#label-Filter+String+to+String+Without+Headers] - - {Filter String to IO Stream}[#label-Filter+String+to+IO+Stream] - - {Filter String to IO Stream with Headers}[#label-Filter+String+to+IO+Stream+with+Headers] - - {Filter String to IO Stream Without Headers}[#label-Filter+String+to+IO+Stream+Without+Headers] - - {Filter IO Stream to String}[#label-Filter+IO+Stream+to+String] - - {Filter IO Stream to String with Headers}[#label-Filter+IO+Stream+to+String+with+Headers] - - {Filter IO Stream to String Without Headers}[#label-Filter+IO+Stream+to+String+Without+Headers] - - {Filter IO Stream to IO Stream}[#label-Filter+IO+Stream+to+IO+Stream] - - {Filter IO Stream to IO Stream with Headers}[#label-Filter+IO+Stream+to+IO+Stream+with+Headers] - - {Filter IO Stream to IO Stream Without Headers}[#label-Filter+IO+Stream+to+IO+Stream+Without+Headers] + - {Filtering String to String}[#label-Filtering+String+to+String] + - {Recipe: Filter String to String with Headers}[#label-Recipe-3A+Filter+String+to+String+with+Headers] + - {Recipe: Filter String to String Without Headers}[#label-Recipe-3A+Filter+String+to+String+Without+Headers] + - {Filtering String to IO Stream}[#label-Filtering+String+to+IO+Stream] + - {Recipe: Filter String to IO Stream with Headers}[#label-Recipe-3A+Filter+String+to+IO+Stream+with+Headers] + - {Recipe: Filter String to IO Stream Without Headers}[#label-Recipe-3A+Filter+String+to+IO+Stream+Without+Headers] + - {Filtering IO Stream to String}[#label-Filtering+IO+Stream+to+String] + - {Recipe: Filter IO Stream to String with Headers}[#label-Recipe-3A+Filter+IO+Stream+to+String+with+Headers] + - {Recipe: Filter IO Stream to String Without Headers}[#label-Recipe-3A+Filter+IO+Stream+to+String+Without+Headers] + - {Filtering IO Stream to IO Stream}[#label-Filtering+IO+Stream+to+IO+Stream] + - {Recipe: Filter IO Stream to IO Stream with Headers}[#label-Recipe-3A+Filter+IO+Stream+to+IO+Stream+with+Headers] + - {Recipe: Filter IO Stream to IO Stream Without Headers}[#label-Recipe-3A+Filter+IO+Stream+to+IO+Stream+Without+Headers] === Parsing: Source Formats You can parse \CSV data from a \String, from a \File (via its path), or from an \IO stream. -==== Parse from \String +==== Parsing from a \String You can parse \CSV data from a \String, with or without headers. -===== Parse from \String with Headers +===== Recipe: Parse from \String with Headers Use class method CSV.parse with option +headers+ to read a source \String all at once (may have memory resource implications): @@ -77,7 +77,7 @@ Ouput: https://github.com/ruby/ruby/blob/trunk/doc/csv/recipes.rdoc#L77 #<CSV::Row "Name":"bar" "Value":"1"> #<CSV::Row "Name":"baz" "Value":"2"> -===== Parse from \String Without Headers +===== Recipe: Parse from \String Without Headers Use class method CSV.parse without option +headers+ to read a source \String all at once (may have memory resource implications): @@ -93,11 +93,11 @@ Output: https://github.com/ruby/ruby/blob/trunk/doc/csv/recipes.rdoc#L93 ["bar", "1"] ["baz", "2"] -==== Parse from \File +==== Parsing from a \File You can parse \CSV data from a \File, with or without headers. -===== Parse from \File with Headers +===== Recipe: Parse from \File with Headers Use instance method CSV#read with option +headers+ to read a file all at once: string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" @@ -114,7 +114,7 @@ Output: https://github.com/ruby/ruby/blob/trunk/doc/csv/recipes.rdoc#L114 #<CSV::Row "Name":"bar" "Value":"1"> #<CSV::Row "Name":"baz" "Value":"2"> -===== Parse from \File Without Headers +===== Recipe: Parse from \File Without Headers Use class meth (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/