question about a small piece of code

G

Gaba Luschi

Hi,

What does the 'w' in the "CSV.open" part of the below code do?

CSV.open('text2.txt','w') do |csv|
people.each do |person|
csv <<person
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

Hi,

What does the 'w' in the "CSV.open" part of the below code do?

CSV.open('text2.txt','w') do |csv|
people.each do |person|
csv <<person
"Write-only, truncates existing file to zero length or creates a new file
for writing"

You can see all the options at the top of this page:
http://ruby-doc.org/core/classes/IO.html
 
M

masdel

Hi,

What does the 'w' in the "CSV.open" part of the below code do?

CSV.open('text2.txt','w') do |csv|
=A0people.each do |person|
=A0 =A0csv <<person

--

write mode

-masdel-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top