-
Notifications
You must be signed in to change notification settings - Fork 123
Experimenting with recipes in CSV RDoc #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
doc/csv/recipes.rdoc
Outdated
|
|
||
| Instance method CSV#read can read a file all at once: | ||
| string = "foo,0\nbar,1\nbaz,2\n" | ||
| CSV.new(string).read # => [["foo", "0"], ["bar", "1"], ["baz", "2"]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSV.read(path)?
doc/csv/recipes.rdoc
Outdated
| File.open(path, headers: true) do |file| | ||
| CSV.parse(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| File.open(path, headers: true) do |file| | |
| CSV.parse(file) | |
| File.open(path) do |file| | |
| CSV.parse(file, headers: true) |
We also need to update output.
doc/csv/recipes.rdoc
Outdated
|
|
||
| in_string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" | ||
| path = 't.csv' | ||
| File.open(path, 'w', headers: true) do |out_io| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| File.open(path, 'w', headers: true) do |out_io| | |
| File.open(path, 'w') do |out_io| |
doc/csv/recipes.rdoc
Outdated
| File.open(path) do |file| | ||
| CSV.filter(in_string, out_string) do |row| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| File.open(path) do |file| | |
| CSV.filter(in_string, out_string) do |row| | |
| File.open(path) do |in_io| | |
| CSV.filter(in_io, out_string) do |row| |
|
Thanks, @kou. Did you like the idea of recipes? If so, there are many more possibilities. |
|
Yes! I like this. |
esparta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minimal typo & phrase suggestion
| ==== Parse from \String Without Headers | ||
|
|
||
| \Class method CSV.parse can read a source \String all at once, | ||
| and so may have memory resource implications: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| and so may have memory resource implications: | |
| be aware this <procedure> may have memory resource implications: |
Not sure about adding procedure or something different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm leaving this as is. CSV.parse is the subject in both clauses, and so the sense, as I see it, is "CSV.parse may have memory resource implications."
|
@kou, this may be ready to merge. |
|
Thanks! |
New Recipes page is oriented to what the user wants to do (instead of what CSV can do). User finds in Contents the relevant task, follows link to get example working code.
Fulsome discussion welcome.