Skip to content

Instantly share code, notes, and snippets.

@Szeliga
Last active March 9, 2016 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Szeliga/e19b9d329119032586ca to your computer and use it in GitHub Desktop.
Save Szeliga/e19b9d329119032586ca to your computer and use it in GitHub Desktop.
Parsing UTF-16LE CSV file
# Open your terminal, navigate to the folder were the book.csv file is residing
# and type irb, when the interactive ruby console launches, type in the following
# it will print first 5 ISBN-13 numbers
require 'csv'
i = 0; CSV.foreach('book.csv', headers: :first_row, encoding: 'UTF-16LE:UTF-8') { |line| break if i == 5; puts line['isbn13']; i += 1 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment