Skip to content

Commit

Permalink
Avoid CSV library for speed.
Browse files Browse the repository at this point in the history
  • Loading branch information
shorowit committed Sep 26, 2024
1 parent d857070 commit 789f081
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rulesets/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def lookup_region_from_zip(zip_code, zip_filepath, zip_column_index, output_colu

fail "Zip code in #{zip_filepath} needs to be 5 digits." if zip_code.size != 5

CSV.foreach(zip_filepath) do |row|
# Note: We don't use the CSV library here because it's slow for large files
File.foreach(zip_filepath) do |row|
row = row.strip.split(',')
next unless row[zip_column_index] == zip_code

return row[output_column_index]
Expand Down

0 comments on commit 789f081

Please sign in to comment.