Skip to content

Instantly share code, notes, and snippets.

@hatappo
Created February 2, 2023 08:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hatappo/53b5e562bdd0d3b207e2faa98cc0848c to your computer and use it in GitHub Desktop.
Save hatappo/53b5e562bdd0d3b207e2faa98cc0848c to your computer and use it in GitHub Desktop.
Parse AWS Invoice PDF file and extract the exchange rate value.
$ ls
Gemfile        a.rb           invoice.us.pdf
bundle install
ruby a.rb
130.2698
require 'pdf-reader'
PDF::Reader.new("invoice.us.pdf").pages[0].text.split("\n").each do |line|
if line.include? 'Exchange Rate'
puts line.split[4].delete("^\.0-9")
end
end
# frozen_string_literal: true
source "https://rubygems.org"
gem "pdf-reader"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment