Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kgryte/apple-card-csv

Convert Apple Card statement transactions to CSV.
https://github.com/kgryte/apple-card-csv

apple apple-card apple-wallet csv excel export javascript mint nodejs parser pdf spreadsheet statement transactions utility

Last synced: 3 months ago
JSON representation

Convert Apple Card statement transactions to CSV.

Awesome Lists containing this project

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

```javascript
var parse = require( 'apple-card-csv' );
```

#### parse( src, clbk )

Parses one or more statements.

```javascript
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.

```text
[
{
'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

```javascript
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

```text
Usage: apple-card-csv [options] [ ...]

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

```bash
$ 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][standard-streams],

```bash
$ 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"
...
```

[standard-streams]: https://en.wikipedia.org/wiki/Standard_streams