Linux heracles.o2switch.net 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
/
opt
/
alt
/
ruby21
/
share
/
ri
/
2.1.0
/
system
/
CSV
/
//opt/alt/ruby21/share/ri/2.1.0/system/CSV/cdesc-CSV.ri
U:RDoc::NormalClass[iI"CSV:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[;o:RDoc::Markup::Paragraph;[I"PThis class provides a complete interface to CSV files and data. It offers ;TI"Qtools to enable you to read and write to and from Strings or IO objects, as ;TI"needed.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI"Reading;T@S;;i; I"From a File;T@S;;i ; I"A Line at a Time;T@o:RDoc::Markup::Verbatim;[I".CSV.foreach("path/to/file.csv") do |row| ;TI" # use row here... ;TI" end ;T:@format0S;;i ; I"All at Once;T@o;;[I"0arr_of_arrs = CSV.read("path/to/file.csv") ;T;0S;;i; I"From a String;T@S;;i ; I"A Line at a Time;T@o;;[I"+CSV.parse("CSV,data,String") do |row| ;TI" # use row here... ;TI" end ;T;0S;;i ; I"All at Once;T@o;;[I"0arr_of_arrs = CSV.parse("CSV,data,String") ;T;0S;;i; I"Writing;T@S;;i; I"To a File;T@o;;[ I"1CSV.open("path/to/file.csv", "wb") do |csv| ;TI"+ csv << ["row", "of", "CSV", "data"] ;TI"! csv << ["another", "row"] ;TI" # ... ;TI" end ;T;0S;;i; I"To a String;T@o;;[ I"(csv_string = CSV.generate do |csv| ;TI"+ csv << ["row", "of", "CSV", "data"] ;TI"! csv << ["another", "row"] ;TI" # ... ;TI" end ;T;0S;;i; I"Convert a Single Line;T@o;;[I"4csv_string = ["CSV", "data"].to_csv # to CSV ;TI"6csv_array = "CSV,String".parse_csv # from CSV ;T;0S;;i; I"Shortcut Interface;T@o;;[ I"MCSV { |csv_out| csv_out << %w{my data here} } # to $stdout ;TI"NCSV(csv = "") { |csv_str| csv_str << %w{my data here} } # to a String ;TI"MCSV($stderr) { |csv_err| csv_err << %w{my data here} } # to $stderr ;TI"NCSV($stdin) { |csv_in| csv_in.each { |row| p row } } # from $stdin ;T;0S;;i; I"Advanced Usage;T@S;;i; I"Wrap an IO Object;T@o;;[I" csv = CSV.new(io, options) ;TI"Q# ... read (with gets() or each()) from and write (with <<) to csv here ... ;T;0S;;i; I">CSV and Character Encodings (M17n or Multilingualization);T@o; ;[I"TThis new CSV parser is m17n savvy. The parser works in the Encoding of the IO ;TI"Tor String object being read from or written to. Your data is never transcoded ;TI"S(unless you ask Ruby to transcode it for you) and will literally be parsed in ;TI"Sthe Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the ;TI"SEncoding of your data. This is accomplished by transcoding the parser itself ;TI"into your Encoding.;T@o; ;[I"SSome transcoding must take place, of course, to accomplish this multiencoding ;TI"Fsupport. For example, <tt>:col_sep</tt>, <tt>:row_sep</tt>, and ;TI"Q<tt>:quote_char</tt> must be transcoded to match your data. Hopefully this ;TI"Qmakes the entire process feel transparent, since CSV's defaults should just ;TI"Qmagically work for you data. However, you can set these values manually in ;TI"2the target Encoding to avoid the translation.;T@o; ;[I"LIt's also important to note that while all of CSV's core parser is now ;TI"JEncoding agnostic, some features are not. For example, the built-in ;TI"Oconverters will try to transcode data to UTF-8 before making conversions. ;TI"RAgain, you can provide custom converters that are aware of your Encodings to ;TI"Javoid this translation. It's just too hard for me to support native ;TI",conversions in all of Ruby's Encodings.;T@o; ;[ I"TAnyway, the practical side of this is simple: make sure IO and String objects ;TI"Spassed into CSV have the proper Encoding set and everything should just work. ;TI"QCSV methods that allow you to open IO objects (CSV::foreach(), CSV::open(), ;TI"MCSV::read(), and CSV::readlines()) do allow you to specify the Encoding.;T@o; ;[ I"ROne minor exception comes when generating CSV into a String with an Encoding ;TI"Othat is not ASCII compatible. There's no existing data for CSV to use to ;TI"Tprepare itself and thus you will probably need to manually specify the desired ;TI"SEncoding for most of those cases. It will try to guess using the fields in a ;TI"Mrow of output though, when using CSV::generate_line() or Array#to_csv().;T@o; ;[I"RI try to point out any other Encoding issues in the documentation of methods ;TI"as they come up.;T@o; ;[ I"SThis has been tested to the best of my ability with all non-"dummy" Encodings ;TI"MRuby ships with. However, it is brave new code and may have some bugs. ;TI"SPlease feel free to {report}[mailto:james@grayproductions.net] any issues you ;TI"find with it.;T: @fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[ I"col_sep;TI"R;T:publicFI"lib/csv.rb;T[ I" encoding;TI"R;T;F@�[ I"field_size_limit;TI"R;T;F@�[ I"lineno;TI"R;T;F@�[ I"quote_char;TI"R;T;F@�[ I"row_sep;TI"R;T;F@�[ I"skip_lines;TI"R;T;F@�[ U:RDoc::Constant[i I"VERSION;FI"CSV::VERSION;T00o;;[o; ;[I"*The version of the installed library.;T;@�;0@�@cRDoc::NormalClass0U;[i I"FieldInfo;FI"CSV::FieldInfo;T00o;;[o; ;[ I"NA FieldInfo Struct contains details about a field's position in the data ;TI"Rsource it was read from. CSV will pass this Struct to some blocks that make ;TI"Jdecisions based on field structure. See CSV.convert_fields() for an ;TI" example.;T@o:RDoc::Markup::List: @type: NOTE:@items[o:RDoc::Markup::ListItem:@label[I"<b><tt>index</tt></b>;T;[o; ;[I"2The zero-based index of the field in its row.;To;;[I"<b><tt>line</tt></b>;T;[o; ;[I"2The line of the data source this row is from.;To;;[I"<b><tt>header</tt></b>;T;[o; ;[I"/The header for the column, when available.;T;@�;0@�@@�0U;[i I"DateMatcher;FI"CSV::DateMatcher;T00o;;[o; ;[I"@A Regexp used to find and convert some common Date formats.;T;@�;0@�@@�0U;[i I"DateTimeMatcher;FI"CSV::DateTimeMatcher;T00o;;[o; ;[I"DA Regexp used to find and convert some common DateTime formats.;T;@�;0@�@@�0U;[i I"ConverterEncoding;FI"CSV::ConverterEncoding;T00o;;[o; ;[I")The encoding used by all converters.;T;@�;0@�@@�0U;[i I"Converters;FI"CSV::Converters;T00o;;[ o; ;[I"RThis Hash holds the built-in converters of CSV that can be accessed by name. ;TI"PYou can select Converters with CSV.convert() or through the +options+ Hash ;TI"passed to CSV::new().;T@o;;;;[o;;[I"<b><tt>:integer</tt></b>;T;[o; ;[I"*Converts any field Integer() accepts.;To;;[I"<b><tt>:float</tt></b>;T;[o; ;[I"(Converts any field Float() accepts.;To;;[I"<b><tt>:numeric</tt></b>;T;[o; ;[I"(A combination of <tt>:integer</tt> ;TI"and <tt>:float</tt>.;To;;[I"<b><tt>:date</tt></b>;T;[o; ;[I".Converts any field Date::parse() accepts.;To;;[I"<b><tt>:date_time</tt></b>;T;[o; ;[I"2Converts any field DateTime::parse() accepts.;To;;[I"<b><tt>:all</tt></b>;T;[o; ;[I"0All built-in converters. A combination of ;TI"/<tt>:date_time</tt> and <tt>:numeric</tt>.;T@o; ;[I"OAll built-in converters transcode field data to UTF-8 before attempting a ;TI"Qconversion. If your data cannot be transcoded to UTF-8 the conversion will ;TI".fail and the field will remain unchanged.;T@o; ;[I"PThis Hash is intentionally left unfrozen and users should feel free to add ;TI":values to it that can be accessed by all CSV objects.;T@o; ;[I"PTo add a combo field, the value should be an Array of names. Combo fields ;TI"+can be nested with other combo fields.;T;@�;0@�@@�0U;[i I"HeaderConverters;FI"CSV::HeaderConverters;T00o;;[ o; ;[I"PThis Hash holds the built-in header converters of CSV that can be accessed ;TI"Lby name. You can select HeaderConverters with CSV.header_convert() or ;TI"5through the +options+ Hash passed to CSV::new().;T@o;;;;[o;;[I"<b><tt>:downcase</tt></b>;T;[o; ;[I"+Calls downcase() on the header String.;To;;[I"<b><tt>:symbol</tt></b>;T;[o; ;[I"0The header String is downcased, spaces are ;TI"4replaced with underscores, non-word characters ;TI"1are dropped, and finally to_sym() is called.;T@o; ;[I"JAll built-in header converters transcode header data to UTF-8 before ;TI"Nattempting a conversion. If your data cannot be transcoded to UTF-8 the ;TI"?conversion will fail and the header will remain unchanged.;T@o; ;[I"PThis Hash is intentionally left unfrozen and users should feel free to add ;TI":values to it that can be accessed by all CSV objects.;T@o; ;[I"PTo add a combo field, the value should be an Array of names. Combo fields ;TI"+can be nested with other combo fields.;T;@�;0@�@@�0U;[i I"DEFAULT_OPTIONS;FI"CSV::DEFAULT_OPTIONS;T00o;;[o; ;[I"MThe options used when no overrides are given by calling code. They are:;T@o;;;;[o;;[I"<b><tt>:col_sep</tt></b>;T;[o; ;[I"<tt>","</tt>;To;;[I"<b><tt>:row_sep</tt></b>;T;[o; ;[I"<tt>:auto</tt>;To;;[I" <b><tt>:quote_char</tt></b>;T;[o; ;[I"<tt>'"'</tt>;To;;[I"&<b><tt>:field_size_limit</tt></b>;T;[o; ;[I" +nil+;To;;[I" <b><tt>:converters</tt></b>;T;[o; ;[I" +nil+;To;;[I"(<b><tt>:unconverted_fields</tt></b>;T;[o; ;[I" +nil+;To;;[I"<b><tt>:headers</tt></b>;T;[o; ;[I"+false+;To;;[I"$<b><tt>:return_headers</tt></b>;T;[o; ;[I"+false+;To;;[I"'<b><tt>:header_converters</tt></b>;T;[o; ;[I" +nil+;To;;[I"!<b><tt>:skip_blanks</tt></b>;T;[o; ;[I"+false+;To;;[I""<b><tt>:force_quotes</tt></b>;T;[o; ;[I"+false+;To;;[I" <b><tt>:skip_lines</tt></b>;T;[o; ;[I" +nil+;T;@�;0@�@@�0[[I"Enumerable;To;;[ ;@�;0@�[[I" class;T[[;[[I"filter;F@�[I"foreach;F@�[I" generate;F@�[I"generate_line;F@�[I" instance;F@�[I"new;T@�[I" open;F@�[I" parse;F@�[I"parse_line;F@�[I" read;F@�[I"readlines;F@�[I" table;F@�[:protected[ [:private[ [I" instance;T[[;[[I"<<;T@�[I"add_row;T@�[I"convert;F@�[I"converters;F@�[I" each;F@�[I"force_quotes?;F@�[I" gets;T@�[I"header_convert;F@�[I"header_converters;F@�[I"header_row?;F@�[I"headers;F@�[I"inspect;F@�[I" puts;T@�[I" read;F@�[I" readline;T@�[I"readlines;T@�[I"return_headers?;F@�[I"rewind;F@�[I" shift;F@�[I"skip_blanks?;F@�[I"unconverted_fields?;F@�[I"write_headers?;F@�[;[ [;[[I"add_converter;F@�[I"add_unconverted_fields;F@�[I"convert_fields;F@�[I"encode_re;F@�[I"encode_str;F@�[I"escape_re;F@�[I"init_comments;F@�[I"init_converters;F@�[I"init_headers;F@�[I"init_parsers;F@�[I"init_separators;F@�[I"parse_headers;F@�[I"raw_encoding;F@�[[I"Forwardable;To;;[o; ;[I"#IO and StringIO Delegation ###;T;@�;0@�[U:RDoc::Context::Section[i 0o;;[ ;0;0[@�@�cRDoc::TopLevel