Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
ruby / usr / share / ri / 2.2.0 / system / CSV / cdesc-CSV.ri
Size: Mime:
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::BlankLineS: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[iI"VERSION;FI"CSV::VERSION;T00o;;[o;	;[I"*The version of the installed library.;T;@‡;0@‡@cRDoc::NormalClass0U;[iI"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;[iI"DateMatcher;FI"CSV::DateMatcher;T00o;;[o;	;[I"@A Regexp used to find and convert some common Date formats.;T;@‡;0@‡@@©0U;[iI"DateTimeMatcher;FI"CSV::DateTimeMatcher;T00o;;[o;	;[I"DA Regexp used to find and convert some common DateTime formats.;T;@‡;0@‡@@©0U;[iI"ConverterEncoding;FI"CSV::ConverterEncoding;T00o;;[o;	;[I")The encoding used by all converters.;T;@‡;0@‡@@©0U;[iI"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;[iI"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;[iI"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[i0o;;[;0;0[@‡@‡cRDoc::TopLevel