apple-card-csv
v1.0.0
Published
Parse an Apple Card statement.
Downloads
5
Maintainers
Readme
Apple Card Statement
Parses an Apple Card statement.
For older Apple devices supporting Apple Wallet (e.g., iPhone 6, iPhone 5, etc), but no longer supporting OS updates (iOS < 13), users are unable to export their Apple Card statements as CSV.
To support these older devices, this package reads and parses exported statement PDFs for subsequent CSV generation.
Usage
var parse = require( 'apple-card-csv' );
parse( src, clbk )
Parses one or more statements.
var resolve = require( 'path' ).resolve;
var cwd = require( '@stdlib/process/cwd' );
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
var fpath = resolve( cwd(), 'path', 'to', 'statement.pdf' );
var src = readFileSync( fpath );
parse( src, done );
function done( error, data ) {
if ( error ) {
return console.error( error.message );
}
console.log( data );
}
To parse more than one statement, provide an Array
of statements, where each element is a Uint8Array
containing statement binary data.
Returned data has the following format:
- Date: transaction date. The field value has the following format:
MM/DD/YYYY
. - Type transaction type; e.g.,
'Transactions'
,'Payments'
,'Interest Charged'
. - Description: transaction description.
- Daily Cash (%): daily cash percentage.
- Daily Cash ($): daily cash amount.
- Amount: transaction amount.
[
{
'Date': '10/03/2019',
'Type': 'Transactions',
'Description': 'FOO BAR',
'Daily Cash (%)': '2%',
'Daily Cash ($)': '$1.29',
'Amount': '$64.31'
},
{
'Date': '10/04/2019',
'Type': 'Transactions',
'Description': 'BEEP BOOP',
'Daily Cash (%)': '2%',
'Daily Cash ($)': '$0.68',
'Amount': '$33.98'
},
...
]
Examples
var join = require( 'path' ).join;
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
var parse = require( 'apple-card-csv' );
var fpath = join( __dirname, 'examples', 'fixtures', 'statement.pdf' );
var src = readFileSync( fpath );
parse( src, done );
function done( error, data ) {
if ( error ) {
return console.error( error.message );
}
console.log( data );
}
CLI
Usage
Usage: apple-card-csv [options] [<file1> <file2> ...]
Options:
-h, --help Print this message.
-V, --version Print the package version.
Notes
- File paths may be either absolute or relative and are resolved relative to the current working directory.
Examples
$ apple-card-csv ./path/to/statement.pdf
Date,Type,Description,Daily Cash (%),Daily Cash ($),Amount
"10/03/2019","Transactions","FOO BAR","2%","$1.29","$64.31"
"10/04/2019","Transactions","BEEP BOOP","2%","$0.68","$33.98"
...
To use as a standard stream,
$ cat ./path/to/statement.pdf | apple-card-csv
"10/03/2019","Transactions","FOO BAR","2%","$1.29","$64.31"
"10/04/2019","Transactions","BEEP BOOP","2%","$0.68","$33.98"
...