-
-
Save hobodave/b6388c180147ce417257 to your computer and use it in GitHub Desktop.
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
def parse_csv(file) | |
uuid_lookup = {} | |
parsed_rows = 0 | |
print "Opening CSV ..." | |
Zlib::GzipReader.open(file) do |csv| | |
puts "DONE" | |
print "Preparing to parse CSV ..." | |
CSV.parse(csv.read, headers: true) do |row| | |
if parsed_rows == 0 | |
puts "READY!" | |
puts "Parsing rows..." | |
end | |
begin | |
uuid_lookup[row['Id']] = UUIDTools::UUID.parse(row['Deal_UUID__c']).raw | |
rescue ArgumentError | |
puts "Ignoring invalid UUID" | |
end | |
parsed_rows += 1 | |
puts "Parsed #{parsed_rows} rows" if 0 == (parsed_rows % 10_000) | |
end | |
end | |
uuid_lookup | |
end | |
uuid_lookup('/var/tmp/sf_uuid_lookup.csv.gz'); nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment