⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
self
/
root
/
usr
/
share
/
ri
/
3.0.0
/
system
/
CSV
/
View File Name :
foreach-c.ri
U:RDoc::AnyMethod[iI"foreach:ETI"CSV::foreach;TT:publico:RDoc::Markup::Document:@parts[2o:RDoc::Markup::Paragraph; [I"CCalls the block with each row read from source +path+ or +io+.;To:RDoc::Markup::BlankLine o:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0; [o; ; [I";Argument +path+, if given, must be the path to a file.;To;;0; [o; ; [I"2Argument +io+ should be an IO object that is:;To;; ;;[o;;0; [o; ; [I"?Open for reading; on return, the IO object will be closed.;To;;0; [o; ; [I""Positioned at the beginning. ;TI"ETo position at the end, for appending, use method CSV.generate. ;TI"GFor any other positioning, pass a preset \StringIO object instead.;To;;0; [o; ; [I"5Argument +mode+, if given, must be a \File mode ;TI";See {Open Mode}[IO.html#method-c-new-label-Open+Mode].;To;;0; [o; ; [I";Arguments
**options
must be keyword options. ;TI"ESee {Options for Parsing}[#class-CSV-label-Options+for+Parsing].;To;;0; [ o; ; [I"LThis method optionally accepts an additional
:encoding
option ;TI"Tthat you can use to specify the Encoding of the data read from +path+ or +io+. ;TI"?You must provide this unless your data is in the encoding ;TI"3given by
Encoding::default_external
. ;TI"?Parsing will use this to determine how to parse the data. ;TI"*You may provide a second Encoding to ;TI"9have the data transcoded as it is read. For example,;To:RDoc::Markup::Verbatim; [I" encoding: 'UTF-32BE:UTF-8' ;T:@format0o; ; [I".would read +UTF-32BE+ data from the file ;TI"0but transcode it to +UTF-8+ before parsing.;T@S:RDoc::Markup::Heading: leveli: textI"Without Option +headers+;T@o; ; [I"DWithout option +headers+, returns each row as an \Array object.;T@o; ; [I".These examples assume prior execution of:;To;; [I"&string = "foo,0\nbar,1\nbaz,2\n" ;TI"path = 't.csv' ;TI"File.write(path, string) ;T;0o; ; [I"%Read rows from a file at +path+:;To;; [I"&CSV.foreach(path) {|row| p row } ;T;0o; ; [I"Output:;To;; [I"["foo", "0"] ;TI"["bar", "1"] ;TI"["baz", "2"] ;T;0o; ; [I""Read rows from an \IO object:;To;; [I"File.open(path) do |file| ;TI"( CSV.foreach(file) {|row| p row } ;TI" end ;T;0o; ; [I"Output:;To;; [I"["foo", "0"] ;TI"["bar", "1"] ;TI"["baz", "2"] ;T;0o; ; [I"1Returns a new \Enumerator if no block given:;To;; [I"ECSV.foreach(path) # => #
;TI"VCSV.foreach(File.open(path)) # => #
, "r")> ;T;0o; ; [I"4Issues a warning if an encoding is unsupported:;To;; [I"@CSV.foreach(File.open(path), encoding: 'foo:bar') {|row| } ;T;0o; ; [I"Output:;To;; [I"/warning: Unsupported encoding foo ignored ;TI"/warning: Unsupported encoding bar ignored ;T;0S;;i;I"With Option +headers+;T@o; ; [I"?With {option +headers+}[#class-CSV-label-Option+headers], ;TI"+returns each row as a CSV::Row object.;T@o; ; [I".These examples assume prior execution of:;To;; [I"2string = "Name,Count\nfoo,0\nbar,1\nbaz,2\n" ;TI"path = 't.csv' ;TI"File.write(path, string) ;T;0o; ; [I"%Read rows from a file at +path+:;To;; [I"5CSV.foreach(path, headers: true) {|row| p row } ;T;0o; ; [I"Output:;To;; [I"*#
;TI"*#
;TI"*#
;T;0o; ; [I""Read rows from an \IO object:;To;; [I"File.open(path) do |file| ;TI"7 CSV.foreach(file, headers: true) {|row| p row } ;TI" end ;T;0o; ; [I"Output:;To;; [I"*#
;TI"*#
;TI"*#
;T;0S:RDoc::Markup::Rule:weighti@o; ; [I"URaises an exception if +path+ is a \String, but not the path to a readable file:;To;; [I"S# Raises Errno::ENOENT (No such file or directory @ rb_sysopen - nosuch.csv): ;TI"(CSV.foreach('nosuch.csv') {|row| } ;T;0o; ; [I"LRaises an exception if +io+ is an \IO object, but not open for reading:;To;; [I"(io = File.open(path, 'w') {|row| } ;TI"E# Raises TypeError (no implicit conversion of nil into String): ;TI"CSV.foreach(io) {|row| } ;T;0o; ; [I".Raises an exception if +mode+ is invalid:;To;; [I":# Raises ArgumentError (invalid access mode nosuch): ;TI")CSV.foreach(path, 'nosuch') {|row| };T;0: @fileI"lib/csv.rb;T:0@omit_headings_from_table_of_contents_below0I"=foreach(path, mode='r', **options) {|row| ... ) foreach(io, mode='r', **options {|row| ... ) foreach(path, mode='r', headers: ..., **options) {|row| ... ) foreach(io, mode='r', headers: ..., **options {|row| ... ) foreach(path, mode='r', **options) -> new_enumerator foreach(io, mode='r', **options -> new_enumerator ;T0[ I"((path, mode="r", **options, &block);T@ÄFI"CSV;TcRDoc::NormalClass00