I downloaded a tab delimited file, and am trying to create a script to read it, but the lines are coming out like this:
"\xFF\xFEu\x00s\x00e\x00r\x00-\x00r\x00e\x00p\x00o\x00r\x00t\x00-\x00s\x00e\x00a
\x00r\x00c\x00h\x00-\x00r\x00e\x00s\x00u\x00l\x00t\x00s\x00-\x002\x000\x001\x004
\x000\x001\x000\x009\x001\x002\x000\x006\x000\x007\x00-\x00G\x00M\x00T\x00.\x00\
t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\x00\t\
x00\r\x00\n"
I believe I need to convert (unicode?) to simple text. Is there a string method that does this? I searched the documentation, but couldn't understand which one does the trick. Below is what I see when I open the file in a regular text editor, for the line quoted above:
"user-report-search-results-20140109120607-GMT."
File.open(path, 'rb:utf-16') do |f|
...
end--
You received this message because you are subscribed to the Google Groups "Ruby Ireland" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby_ireland...@googlegroups.com.
To post to this group, send an email to ruby_i...@googlegroups.com.
Visit this group at http://groups.google.com/group/ruby_ireland.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "Ruby Ireland" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby_ireland...@googlegroups.com.
To post to this group, send an email to ruby_i...@googlegroups.com.
Visit this group at http://groups.google.com/group/ruby_ireland.
For more options, visit https://groups.google.com/groups/opt_out.
CSV.foreach(filename, { :row_sep => :auto, :col_sep => “\t" }) do |row|