Created
July 5, 2018 20:34
-
-
Save doyle/557fba170fdff7c46126061c15331339 to your computer and use it in GitHub Desktop.
How to read the headers of a CSV file without reading the whole file
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
header_string = File.open(file_path, 'r:bom|utf-8', &:readline) | |
headers = CSV.parse(header_string).first |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment