ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
instance-c.ri 0000644 00000001317 15240245572 0007134 0 ustar 00 U:RDoc::AnyMethod[iI"
instance:EFI"CSV::instance;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"KThis method will return a CSV instance, just like CSV::new(), but the ;TI"Rinstance will be cached and returned for all future calls to this method for ;TI"Ithe same +data+ object (tested by Object#object_id()) with the same ;TI"+options+.;To:RDoc::Markup::BlankLine o;
; [I"MIf a block is given, the instance is passed to the block and the return ;TI"1value becomes the return value of the block.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below00I"
instance;T[ I")(data = $stdout, options = Hash.new);T@FI"CSV;TcRDoc::NormalClass00 escape_re-i.ri 0000644 00000001167 15240245572 0007267 0 ustar 00 U:RDoc::AnyMethod[iI"escape_re:EFI"CSV#escape_re;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I"RThis method is an encoding safe version of Regexp::escape(). It will escape ;TI"Qany characters that would change the meaning of a regular expression in the ;TI"Qencoding of +str+. Regular expression characters that cannot be transcoded ;TI"Qto the target encoding will be skipped and no escaping will be performed if ;TI"&a backslash cannot be transcoded.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"
(str);T@FI"CSV;TcRDoc::NormalClass00 write_headers%3f-i.ri 0000644 00000000531 15240245572 0010456 0 ustar 00 U:RDoc::AnyMethod[iI"write_headers?:EFI"CSV#write_headers?;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"OReturns +true+ if headers are written in output. See CSV::new for details.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"();T@FI"CSV;TcRDoc::NormalClass00 encode_re-i.ri 0000644 00000000571 15240245572 0007262 0 ustar 00 U:RDoc::AnyMethod[iI"encode_re:EFI"CSV#encode_re;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"NBuilds a regular expression in @encoding. All +chunks+ will be ;TI"!transcoded to that encoding.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(*chunks);T@FI"CSV;TcRDoc::NormalClass00 readline-i.ri 0000644 00000000355 15240245572 0007122 0 ustar 00 U:RDoc::AnyMethod[iI"
readline:ETI"CSV#readline;TF:publico:RDoc::Markup::Document:@parts[ :
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"();T@FI"CSV;TcRDoc::NormalClass0[@FI"
shift;F header_row%3f-i.ri 0000644 00000000502 15240245572 0007746 0 ustar 00 U:RDoc::AnyMethod[iI"header_row?:EFI"CSV#header_row?;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I">Returns +true+ if the next row read will be a header row.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"();T@FI"CSV;TcRDoc::NormalClass00 inspect-i.ri 0000644 00000000541 15240245572 0007001 0 ustar 00 U:RDoc::AnyMethod[iI"inspect:EFI"CSV#inspect;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"FReturns a simplified description of the key CSV attributes in an ;TI"ASCII compatible String.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"();T@FI"CSV;TcRDoc::NormalClass00 shift-i.ri 0000644 00000001156 15240245572 0006454 0 ustar 00 U:RDoc::AnyMethod[iI"
shift:EFI"CSV#shift;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"QThe primary read method for wrapped Strings and IOs, a single row is pulled ;TI"Pfrom the data source, parsed and returned as an Array of fields (if header ;TI"Brows are not used) or a CSV::Row (when header rows are used).;To:RDoc::Markup::BlankLine o;
; [I".The data source must be open for reading.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[[I" gets;To;; [ ;@;
0[I"
readline;To;; [ ;@;
0I"();T@FI"CSV;TcRDoc::NormalClass00 init_comments-i.ri 0000644 00000001016 15240245572 0010202 0 ustar 00 U:RDoc::AnyMethod[iI"init_comments:EFI"CSV#init_comments;TF:privateo:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [I"FStores the pattern of comments to skip from the provided options.;To:RDoc::Markup::BlankLine o;
; [I"IThe pattern must respond to +.match+, else ArgumentError is raised. ;TI"'Strings are converted to a Regexp.;T@o;
; [I"See also CSV.new;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(options);T@FI"CSV;TcRDoc::NormalClass00 header_converters-i.ri 0000644 00000000717 15240245572 0011043 0 ustar 00 U:RDoc::AnyMethod[iI"header_converters:EFI"CSV#header_converters;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"QReturns the current list of converters in effect for headers. See CSV::new ;TI"Nfor details. Built-in converters will be returned by name, while others ;TI"will be returned as is.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"();T@FI"CSV;TcRDoc::NormalClass00 read-c.ri 0000644 00000001650 15240245572 0006243 0 ustar 00 U:RDoc::AnyMethod[iI" read:EFI"CSV::read;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"NUse to slurp a CSV file into an Array of Arrays. Pass the +path+ to the ;TI"Rfile and any +options+ CSV::new() understands. This method also understands ;TI"Pan additional :encoding parameter that you can use to specify the ;TI"OEncoding of the data in the file to be read. You must provide this unless ;TI"Syour data is in Encoding::default_external(). CSV will use this to determine ;TI"Phow to parse the data. You may provide a second Encoding to have the data ;TI"-transcoded as it is read. For example, ;TI"Pencoding: "UTF-32BE:UTF-8" would read UTF-32BE data from the file ;TI"4but transcode it to UTF-8 before CSV parses it.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(path, *options);T@FI"CSV;TcRDoc::NormalClass00 encoding-i.ri 0000644 00000000613 15240245572 0007122 0 ustar 00 U:RDoc::Attr[iI"
encoding:ETI"CSV#encoding;TI"R;T:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"OThe Encoding CSV is parsing or writing in. This will be the Encoding you ;TI"Hreceive parsed data in and/or the Encoding data will be written in.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0F@I"CSV;TcRDoc::NormalClass0 skip_lines-i.ri 0000644 00000000472 15240245572 0007477 0 ustar 00 U:RDoc::Attr[iI"skip_lines:ETI"CSV#skip_lines;TI"R;T:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"DThe regex marking a line as a comment. See CSV::new for details;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0F@I"CSV;TcRDoc::NormalClass0 new-c.ri 0000644 00000015455 15240245572 0006131 0 ustar 00 U:RDoc::AnyMethod[iI"new:ETI"
CSV::new;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I"RThis constructor will wrap either a String or IO object passed in +data+ for ;TI"Rreading and/or writing. In addition to the CSV instance methods, several IO ;TI"Qmethods are delegated. (See CSV::open() for a complete list.) If you pass ;TI"Na String for +data+, you can later retrieve it (after writing to it, for ;TI" example) with CSV.string().;To:RDoc::Markup::BlankLine o;
; [I"LNote that a wrapped String will be positioned at at the beginning (for ;TI"Nreading). If you want it at the end (for writing), use CSV::generate(). ;TI"NIf you want any other positioning, pass a preset StringIO object instead.;T@o;
; [I"OYou may set any reading and/or writing preferences in the +options+ Hash. ;TI"Available options are:;T@o:RDoc::Markup::List:
@type: NOTE:@items[o:RDoc::Markup::ListItem:@label[I":col_sep;T; [o;
; [I"+The String placed between each field. ;TI")This String will be transcoded into ;TI"(the data's Encoding before parsing.;To;;[I":row_sep;T; [o;
; ["I",The String appended to the end of each ;TI"*row. This can be set to the special ;TI",:auto setting, which requests ;TI"*that CSV automatically discover this ;TI"*from the data. Auto-discovery reads ;TI",ahead in the data looking for the next ;TI"("\r\n", "\n", or ;TI")"\r" sequence. A sequence ;TI"+will be selected even if it occurs in ;TI"'a quoted field, assuming that you ;TI"&would have the same line endings ;TI"+there. If none of those sequences is ;TI"%found, +data+ is ARGF, ;TI")STDIN, STDOUT, or ;TI",STDERR, or the stream is only ;TI"'available for output, the default ;TI"&$INPUT_RECORD_SEPARATOR ;TI"(($/) is used. Obviously, ;TI")discovery takes a little time. Set ;TI"+manually if speed is important. Also ;TI"+note that IO objects should be opened ;TI"'in binary mode on Windows if this ;TI"!feature will be used as the ;TI"'line-ending translation can cause ;TI"*problems with resetting the document ;TI")position to where it was before the ;TI"%read ahead. This String will be ;TI")transcoded into the data's Encoding ;TI"before parsing.;To;;[I" :quote_char;T; [o;
; [I")The character used to quote fields. ;TI"'This has to be a single character ;TI"!String. This is useful for ;TI"&application that incorrectly use ;TI"'' as the quote character ;TI"(instead of the correct ". ;TI"'CSV will always consider a double ;TI"&sequence this character to be an ;TI"(escaped quote. This String will be ;TI")transcoded into the data's Encoding ;TI"before parsing.;To;;[I"&:field_size_limit;T; [o;
; [I"*This is a maximum size CSV will read ;TI")ahead looking for the closing quote ;TI"*for a field. (In truth, it reads to ;TI"'the first line ending beyond this ;TI"(size.) If a quote cannot be found ;TI"'within the limit CSV will raise a ;TI"*MalformedCSVError, assuming the data ;TI"+is faulty. You can use this limit to ;TI"&prevent what are effectively DoS ;TI"+attacks on the parser. However, this ;TI"+limit can cause a legitimate parse to ;TI",fail and thus is set to +nil+, or off, ;TI"by default.;To;;[I" :converters;T; [o;
; [I"+An Array of names from the Converters ;TI",Hash and/or lambdas that handle custom ;TI"%conversion. A single converter ;TI"*doesn't have to be in an Array. All ;TI"*built-in converters try to transcode ;TI"(fields to UTF-8 before converting. ;TI"*The conversion will fail if the data ;TI"'cannot be transcoded, leaving the ;TI"field unchanged.;To;;[I"(:unconverted_fields;T; [o;
; [I"If set to +true+, an ;TI")unconverted_fields() method will be ;TI"*added to all returned rows (Array or ;TI"+CSV::Row) that will return the fields ;TI"+as they were before conversion. Note ;TI"(that :headers supplied by ;TI",Array or String were not fields of the ;TI"*document and thus will have an empty ;TI"Array attached.;To;;[I":headers;T; [o;
; [I"&If set to :first_row or ;TI"(+true+, the initial row of the CSV ;TI"&file will be treated as a row of ;TI"'headers. If set to an Array, the ;TI"+contents will be used as the headers. ;TI"+If set to a String, the String is run ;TI")through a call of CSV::parse_line() ;TI"&with the same :col_sep, ;TI":row_sep, and ;TI"+:quote_char as this instance ;TI"+to produce an Array of headers. This ;TI"*setting causes CSV#shift() to return ;TI")rows as CSV::Row objects instead of ;TI"%Arrays and CSV#read() to return ;TI",CSV::Table objects instead of an Array ;TI"of Arrays.;To;;[I"$:return_headers;T; [o;
; [I",When +false+, header rows are silently ;TI"*swallowed. If set to +true+, header ;TI",rows are returned in a CSV::Row object ;TI" with identical headers and ;TI",fields (save that the fields do not go ;TI"through the converters).;To;;[I"#:write_headers;T; [o;
; [I"*When +true+ and :headers is ;TI",set, a header row will be added to the ;TI"output.;To;;[I"':header_converters;T; [o;
; [
I"#Identical in functionality to ;TI"(:converters save that the ;TI")conversions are only made to header ;TI"+rows. All built-in converters try to ;TI"'transcode headers to UTF-8 before ;TI"+converting. The conversion will fail ;TI"'if the data cannot be transcoded, ;TI""leaving the header unchanged.;To;;[I"!:skip_blanks;T; [o;
; [I"*When set to a +true+ value, CSV will ;TI"(skip over any rows with no content.;To;;[I"":force_quotes;T; [o;
; [I"*When set to a +true+ value, CSV will ;TI"%quote all CSV fields it creates.;To;;[I" :skip_lines;T; [o;
; [I")When set to an object responding to ;TI")match, every line matching ;TI",it is considered a comment and ignored ;TI"+during parsing. When set to a String, ;TI"(it is first converted to a Regexp. ;TI"-When set to +nil+ no line is considered ;TI"*a comment. If the passed object does ;TI"$not respond to match, ;TI"&ArgumentError is thrown.;T@o;
; [I"7See CSV::DEFAULT_OPTIONS for the default settings.;T@o;
; [I"SOptions cannot be overridden in the instance methods for performance reasons, ;TI"*so be sure to set what you want here.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(data, options = Hash.new);T@æFI"CSV;TcRDoc::NormalClass00 return_headers%3f-i.ri 0000644 00000000561 15240245572 0010646 0 ustar 00 U:RDoc::AnyMethod[iI"return_headers?:EFI"CSV#return_headers?;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"EReturns +true+ if headers will be returned as a row of results. ;TI"See CSV::new for details.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"();T@FI"CSV;TcRDoc::NormalClass00 parse-c.ri 0000644 00000001351 15240245572 0006440 0 ustar 00 U:RDoc::AnyMethod[iI"
parse:EFI"CSV::parse;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"RThis method can be used to easily parse CSV out of a String. You may either ;TI"Qprovide a +block+ which will be called with each row of the String in turn, ;TI"Ior just use the returned Array of Arrays (when no +block+ is given).;To:RDoc::Markup::BlankLine o;
; [I"QYou pass your +str+ to read from, and an optional +options+ Hash containing ;TI"%anything CSV::new() understands.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0I"Uparse( str, options = Hash.new ) { |row| ... }
parse( str, options = Hash.new )
;T0[ I"(*args, &block);T@FI"CSV;TcRDoc::NormalClass00 puts-i.ri 0000644 00000000345 15240245572 0006331 0 ustar 00 U:RDoc::AnyMethod[iI" puts:ETI"
CSV#puts;TF:publico:RDoc::Markup::Document:@parts[ :
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"
(row);T@FI"CSV;TcRDoc::NormalClass0[@FI"<<;T encode_str-i.ri 0000644 00000000557 15240245572 0007470 0 ustar 00 U:RDoc::AnyMethod[iI"encode_str:EFI"CSV#encode_str;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"PBuilds a String in @encoding. All +chunks+ will be transcoded to ;TI"that encoding.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(*chunks);T@FI"CSV;TcRDoc::NormalClass00 add_converter-i.ri 0000644 00000001257 15240245572 0010160 0 ustar 00 U:RDoc::AnyMethod[iI"add_converter:EFI"CSV#add_converter;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"RThe actual work method for adding converters, used by both CSV.convert() and ;TI"CSV.header_convert().;To:RDoc::Markup::BlankLine o;
; [I"OThis method requires the +var_name+ of the instance variable to place the ;TI"Lconverters in, the +const+ Hash to lookup named converters in, and the ;TI"Mnormal parameters of the CSV.convert() and CSV.header_convert() methods.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I".(var_name, const, name = nil, &converter);T@FI"CSV;TcRDoc::NormalClass00 filter-c.ri 0000644 00000002642 15240245572 0006617 0 ustar 00 U:RDoc::AnyMethod[iI"filter:EFI"CSV::filter;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"OThis method is a convenience for building Unix-like filters for CSV data. ;TI"MEach row is yielded to the provided block which can alter it as needed. ;TI"MAfter the block returns, the row is appended to +output+ altered or not.;To:RDoc::Markup::BlankLine o;
; [I"KThe +input+ and +output+ arguments can be anything CSV::new() accepts ;TI"F(generally String or IO objects). If not given, they default to ;TI"(ARGF and $stdout.;T@o;
; [I"LThe +options+ parameter is also filtered down to CSV::new() after some ;TI"Bclever key parsing. Any key beginning with :in_ or ;TI"O:input_ will have that leading identifier stripped and will only ;TI"Obe used in the +options+ Hash for the +input+ object. Keys starting with ;TI"O:out_ or :output_ affect only +output+. All other keys ;TI""are assigned to both objects.;T@o;
; [I"7The :output_row_sep +option+ defaults to ;TI"4$INPUT_RECORD_SEPARATOR ($/).;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0I"—filter( options = Hash.new ) { |row| ... }
filter( input, options = Hash.new ) { |row| ... }
filter( input, output, options = Hash.new ) { |row| ... }
;TI"row;T[ I"(*args);T@"FI"CSV;TcRDoc::NormalClass00 generate-c.ri 0000644 00000002111 15240245572 0007113 0 ustar 00 U:RDoc::AnyMethod[iI"
generate:EFI"CSV::generate;TT:publico:RDoc::Markup::Document:@parts[
o:RDoc::Markup::Paragraph; [ I"NThis method wraps a String you provide, or an empty default String, in a ;TI"QCSV object which is passed to the provided block. You can use the block to ;TI"Nappend CSV rows to the String and when the block exits, the final String ;TI"will be returned.;To:RDoc::Markup::BlankLine o;
; [I"PNote that a passed String *is* modified by this method. Call dup() before ;TI"&passing if you need a new String.;T@o;
; [ I"RThe +options+ parameter can be anything CSV::new() understands. This method ;TI"Nunderstands an additional :encoding parameter when not passed a ;TI"QString to set the base Encoding for the output. CSV needs this hint if you ;TI".plan to output non-ASCII compatible data.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0I"dgenerate( str, options = Hash.new ) { |csv| ... }
generate( options = Hash.new ) { |csv| ... }
;TI"csv;T[ I"(*args);T@FI"CSV;TcRDoc::NormalClass00 parse_headers-i.ri 0000644 00000001415 15240245572 0010142 0 ustar 00 U:RDoc::AnyMethod[iI"parse_headers:EFI"CSV#parse_headers;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I"PThis method is used to turn a finished +row+ into a CSV::Row. Header rows ;TI"Mare also dealt with here, either by returning a CSV::Row with identical ;TI"Pheaders and fields (save that the fields do not go through the converters) ;TI"Nor by reading past them to return a field row. Headers are also saved in ;TI".@headers for use in future rows.;To:RDoc::Markup::BlankLine o;
; [I"PWhen +nil+, +row+ is assumed to be a header row not based on an actual row ;TI"of the stream.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(row = nil);T@FI"CSV;TcRDoc::NormalClass00 quote_char-i.ri 0000644 00000000532 15240245572 0007466 0 ustar 00 U:RDoc::Attr[iI"quote_char:ETI"CSV#quote_char;TI"R;T:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"QThe encoded :quote_char used in parsing and writing. See CSV::new ;TI"for details.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0F@I"CSV;TcRDoc::NormalClass0 convert_fields-i.ri 0000644 00000001171 15240245572 0010342 0 ustar 00 U:RDoc::AnyMethod[iI"convert_fields:EFI"CSV#convert_fields;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [
I"RProcesses +fields+ with @converters, or @header_converters ;TI"Oif +headers+ is passed as +true+, returning the converted field set. Any ;TI"Oconverter that changes the field into something other than a String halts ;TI"Qthe pipeline of conversion for that field. This is primarily an efficiency ;TI"shortcut.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(fields, headers = false);T@FI"CSV;TcRDoc::NormalClass00 cdesc-CSV.ri 0000644 00000025734 15240245572 0006633 0 ustar 00 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, :col_sep, :row_sep, and ;TI"Q:quote_char 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"index;T;[o; ;[I"2The zero-based index of the field in its row.;To;;[I"line;T;[o; ;[I"2The line of the data source this row is from.;To;;[I"header;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":integer;T;[o; ;[I"*Converts any field Integer() accepts.;To;;[I":float;T;[o; ;[I"(Converts any field Float() accepts.;To;;[I":numeric;T;[o; ;[I"(A combination of :integer ;TI"and :float.;To;;[I":date;T;[o; ;[I".Converts any field Date::parse() accepts.;To;;[I":date_time;T;[o; ;[I"2Converts any field DateTime::parse() accepts.;To;;[I":all;T;[o; ;[I"0All built-in converters. A combination of ;TI"/:date_time and :numeric.;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":downcase;T;[o; ;[I"+Calls downcase() on the header String.;To;;[I":symbol;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":col_sep;T;[o; ;[I"",";To;;[I":row_sep;T;[o; ;[I":auto;To;;[I" :quote_char;T;[o; ;[I"'"';To;;[I"&:field_size_limit;T;[o; ;[I"
+nil+;To;;[I" :converters;T;[o; ;[I"
+nil+;To;;[I"(:unconverted_fields;T;[o; ;[I"
+nil+;To;;[I":headers;T;[o; ;[I"+false+;To;;[I"$:return_headers;T;[o; ;[I"+false+;To;;[I"':header_converters;T;[o; ;[I"
+nil+;To;;[I"!:skip_blanks;T;[o; ;[I"+false+;To;;[I"":force_quotes;T;[o; ;[I"+false+;To;;[I" :skip_lines;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 Row/values_at-i.ri 0000644 00000000431 15240245572 0010064 0 ustar 00 U:RDoc::AnyMethod[iI"values_at:ETI"CSV::Row#values_at;TF:publico:RDoc::Markup::Document:@parts[ :
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(*headers_and_or_indices);T@FI"Row;TcRDoc::NormalClass0[I"
CSV::Row;TFI"fields;F Row/has_key%3f-i.ri 0000644 00000000644 15240245572 0010030 0 ustar 00 U:RDoc::AnyMethod[iI"
has_key?:EFI"CSV::Row#has_key?;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"@Returns +true+ if there is a field with the given +header+.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below000[[I"
include?;To;; [ ;@;0[I" key?;To;; [ ;@;0[I"member?;To;; [ ;@;0I"
(header);T@FI"Row;TcRDoc::NormalClass00 Row/field-i.ri 0000644 00000001342 15240245572 0007166 0 ustar 00 U:RDoc::AnyMethod[iI"
field:EFI"CSV::Row#field;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"QThis method will return the field value by +header+ or +index+. If a field ;TI"%is not found, +nil+ is returned.;To:RDoc::Markup::BlankLine o;
; [I"LWhen provided, +offset+ ensures that a header match occurs on or later ;TI"Kthan the +offset+ index. You can use this to find duplicate headers, ;TI"4without resorting to hard-coding exact indices.;T:
@fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0I"