Last active
October 21, 2016 08:54
-
-
Save yucao24hours/9261de4da88a94f46086b76bf6d62284 to your computer and use it in GitHub Desktop.
データにダブルクオートがはいっていると Ruby が勝手にエスケープしてくれる https://tools.ietf.org/html/rfc4180
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "csv" | |
CSV.open("mogemoge.csv", "w+") do |csv| | |
array = %w(foo bar baz piyo) | |
double_quoted = array.map{|item| %Q|"#{item}"| } | |
p double_quoted | |
csv << double_quoted | |
end |
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4. in line 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat mogemoge.csv | |
"""foo""","""bar""","""baz""","""piyo""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
まあそもそもこんな文字列出すことなんてあんまりないとおもうけど...