Paxmex

I built this gem initially for internal use at Lumos Labs so that we could parse the AMEX data files that were provided by AMEX everyday. Their spec was terribly outdated (it states that you can ftp into their servers with a 9600 Baud Modem, that's how old it was!) and their files were unnecessarily tedious to parse. After we made sure that things worked for our usage, we decided to open source it to the Ruby community. It is especially useful if your company/organization processes AMEX transactions. It is MIT licensed so feel free to fork and contribute!

Installation

You can get the gem from RubyGems. Just run the following command in your terminal:

% gem install paxmex

Available Methods

Both methods return a readable hash in the following format:

{
  "DATA_FILE_TRAILER_RECORD" => {
    "DF_TRL_RECORD_TYPE" => "DFTRL",
    "DF_TRL_DATE" => #<Date: 2013-04-05>,
    "DF_TRL_TIME" => "0435",
    "DF_TRL_FILE_ID" => 0,
    "DF_TRL_FILE_NAME" => "LUMOS LABS INC",
    "DF_TRL_RECIPIENT_KEY" => "00000000002754170029          0000000000",
    "DF_TRL_RECORD_COUNT" => 4
  },
  "DATA_FILE_HEADER_RECORD" => {
    "DF_HDR_RECORD_TYPE" => "DFHDR",
    "DF_HDR_DATE" => #<Date: 2013-04-05>,
    "DF_HDR_TIME" => "0435",
    "DF_HDR_FILE_ID" => 0,
    "DF_HDR_FILE_NAME" => "LUMOS LABS INC"
  },
  .
  .
  .
}

Values are parsed from their representation into a corresponding native Ruby type:

If you'd like the raw values to be returned instead, you can set the raw_values option to true, e.g.:

Paxmex.parse_eptrn(path_to_file, raw_values: true)
Paxmex.parse_epraw(path_to_file, raw_values: true)

Example Usage

require 'paxmex'
Paxmex.parse_eptrn('/path/to/amex/eptrn/raw/file')
Paxmex.parse_epraw('/path/to/amex/epraw/raw/file')

The input files for either methods is a data report file provided by American Express. These files are in either EPRAW or EPTRN format so use the relevant method to parse them. We have provided dummy EPRAW and EPTRN files in spec/support. Output and key-value pairs vary depending on whether you choose to parse an EPTRN or EPRAW file.

We hope this makes your interaction with AMEX a lot less painful.

You can check out the GitHub repository here.