Skip to content

Instantly share code, notes, and snippets.

@hobodave
Last active August 29, 2015 14:17
Show Gist options
  • Save hobodave/b6388c180147ce417257 to your computer and use it in GitHub Desktop.
Save hobodave/b6388c180147ce417257 to your computer and use it in GitHub Desktop.
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