Project Website | Online Demo | Forum | Documentation-Wiki | Bug-Tracker
It is currently Tue Sep 07, 2010 1:52 pm

All times are UTC + 1 hour [ DST ]





Post new topic Reply to topic  [ 2 posts ] 
  Print view Previous topic | Next topic 
Author Message
 Post subject: Chase bank CSV import parser
PostPosted: Fri Jun 11, 2010 7:16 am 
Offline

Joined: Fri Jun 11, 2010 7:07 am
Posts: 2
Hi,
Badger is exactly what I was looking for, the closest I've come to a replacement of Rudder.com's capabilities along with MS Money 2002. (sad to rely on those...) Everything else falls so short since I rely so heavily on forecasting.

I need help in getting Chase bank's CSV imported. I've tried Chase Visa parser, but I'm guessing it's different.

Here are a few lines of the CSV for my chase bank account:

DEBIT,06/09/2010,"QT 411 PHOENIX AZ 633368 06/08QT 411 PH",-8.12
DEBIT,06/09/2010,"PAYPAL INST XFER 5A6224AB7TAL4 WEB ID: PAYPALSI66",-4.35
DEBIT,06/09/2010,"PAYPAL INST XFER 5A6224AB8CA3G WEB ID: PAYPALSI66",-2.38
DEBIT,06/08/2010,"MAMA'S PIZZERIA SCOTTSD 06/06MAMA'S P",-14.03
DEBIT,06/08/2010,"BEVERAGES & MORE #87 SCO867971 06/07BEVERAGES",-13.03
DEBIT,06/08/2010,"SAFEWAY STORE 1549 SCO124295 06/07SAFEWAY",-5.07
DEBIT,06/08/2010,"Online Transfer to CHK XXXXXXXXXX transaction#: 389676893",-775.00
CREDIT,06/07/2010,"ATM CHECK DEPOSIT",1018.88

EDIT:
One I found different was this:
DSLIP,05/14/2010,"DEPOSIT ID NUMBER 634604",425.00


Top
 Profile  
 
 Post subject: Re: Chase bank CSV import parser
PostPosted: Fri Jun 11, 2010 8:19 pm 
Offline

Joined: Fri Jun 11, 2010 7:07 am
Posts: 2
I've thrown together a hacked version of another parser.
It does the job.

Here it is, for Chase bank USA CSV import:

<?php
/*
* ____ _____ _____ ______ _____
*| _ \ /\ | __ \ / ____| ____| __ \
*| |_) | / \ | | | | | __| |__ | |__) |
*| _ < / /\ \ | | | | | |_ | __| | _ /
*| |_) / ____ \| |__| | |__| | |____| | \ \
*|____/_/ \_\_____/ \_____|______|_| \_\
* Open Source Finance Management
* Visit http://www.badger-finance.org
*
* Parse .csv files from Chase Bank .
**/

// The next line determines the displayed name of this parser.
// BADGER_REAL_PARSER_NAME Chase Bank

/**
* transform csv to array
*
* File to store: ..\modules\csvImport\parser\ChaseBank.php
*
* @param $fp filepointer, $accountId
* @return array (categoryId, accountId, title, description, valutaDate, amount, transactionPartner)
*/

function parseToArray($fp, $accountId){
/**
* count Rows of csv
*
* @var int
*/
$csvRow = 0;
/**
* is set true, a line contains "\t" (tabs), but not the correct number for t
his parser (5)
*
* @var boolean
*/
$noValidFile = NULL;

/**
* is set true, after the header was ignored
*
* @var boolean
*/
$headerIgnored = TRUE;
function avoid_bad_sign($strings) {
$strings = str_replace("\"", "", $strings);
$strings = str_replace("\\", "", $strings);
$strings = str_replace("\n", " ",$strings);
$strings = str_replace("\r", " ",$strings);
return $strings;
}


$rowArray = NULL;

//if array is not empty or is no header
while ($transactionArray = fgetcsv ($fp, 1024, ",")) {
if (!empty ($transactionArray[0]) ) {
//if array contains excactly 4 fields , to ensure it is a valid csv
file
if ( count ($transactionArray) == 4) {

//format date YY-MM-DD or YYYY-MM-DD
// Chase CSV format: MM/DD/YYYY
$transactionArray[2] = avoid_bad_sign($transactionArray[2]);
$valutaDate[0] = substr($transactionArray[1],0,2);
$valutaDate[1] = substr($transactionArray[1],3,2);
$valutaDate[2] = substr($transactionArray[1],6,4);
$valutaDate[4] = $valutaDate[2] . "-" . $valutaDate[0] . "-" . $v
alutaDate[1];
$valutaDate1 = new Date($valutaDate[4]);

//avoid " & \ in the title & description, those characters could
cause problems
// number of checks
$transactionArray[0] = avoid_bad_sign($transactionArray[0]);
$transactionArray[2] = avoid_bad_sign($transactionArray[2]);
$transactionArray[3] = avoid_bad_sign($transactionArray[3]);
$amount = new Amount($transactionArray[3]);
/**
* transaction array
*
* @var array
*/
$rowArray = array (
"categoryId" => "",
"accountId" => $accountId,
"title" => substr($transactionArray[2],0,99), // cut title with m
ore than 100 chars
"description" => $transactionArray[2].', '.$transactionArray[3],
"valutaDate" => $valutaDate1,
"amount" => $amount,
"transactionPartner" => "Change by yourself"
);

} else{
$noValidFile = 'true';
}
}

// if a row contains valid data
if ($rowArray){
/**
* array of all transaction arrays
*
* @var array
*/
$importedTransactions[$csvRow] = $rowArray;
$csvRow++;
}
}
if ($noValidFile) {
throw new badgerException('importCsv', 'wrongSeperatorNumber');
//close file
fclose ($fp);
} else {
if ($csvRow == 0){
throw new badgerException('importCsv', 'noSeperator');
//close file
fclose ($fp);
} else{
//close file
fclose ($fp);
return $importedTransactions;
}
}
}
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron




Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style supported by CodeMiles Team.