Created
March 23, 2012 04:42
-
-
Save labocho/2166865 to your computer and use it in GitHub Desktop.
CSV を文字コード変換しつつロード ref: http://qiita.com/items/8559576b71642b79df67
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
CSV.foreach(filename, encoding: "Shift_JIS:UTF-8") do |row| | |
# … | |
end |
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
open(filename, "rb:Shift_JIS:UTF-8", undef: :replace) do |f| | |
# … | |
end |
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
open(filename, "rb:Shift_JIS:UTF-8", undef: :replace) do |f| | |
CSV.new(f).each do |row| | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment