Kesavan Muthuvel's Personal Home Page

Index | Bookmarks | I'm supporting | More info? | Royal Thunderbird! | Maemo N900 | Nexus 4 (Android + more ) | KODI [aka] XBMC | My Public Key (GPG) | My Sign | Travel Photos | Blog
Thanks to.. | Open Materials | interview qns | scripts to look | RegEx me! | Web Dev tips | eBooks Collection
Looking for a girl A day - a cartoon Shameless self promo Generate random values

Sample qns for: I'm just fresher | oops | yahoo! | cognizant | consim | advanced? | generic | I don't Know | Zend Frame Works


Welcome to the Currency Solutions Test Pack.

Your test pack will include:
* This readme file
* The bank statement file (statement.csv)
* The skeleton class (Bootstrap.php)

We want to parse the bank statement to deduce the total value of payments made on 6 March 2011 for
each currency.  All lines of the bank statement that represent a payment will contain a payment 
reference in one of it's narratives.  A payment reference is guaranteed to be the letters "PAY" 
then 6 digits and then two more letters (e.g. PAY000001YB).  The currencies that we deal with for 
the purpose of this exercise are GBP, EUR, USD and CAD.

Sample Output:

GBP 3,432.21
USD 13,432.34
EUR 43,543.23
CAD 2,321.34

* Complete the skeleton class so that running "php Bootstrap.php statement.csv" on the commandline 
  will parse the bank statement file and output the sample output above.
* You may add additional classes to complete the task.
* Please return the completed test pack including any additional files as a single zip archive.
* This test should not take longer than 30 minutes.

__Sample statement.csv__ 

"Date","Narrative 1","Narrative 2","Narrative 3","Narrative 4","Narrative 5","Type","Credit","Debit","Currency"
"06-03-2011","CURSOL",10067441,"CURSOL","CURRENCY SOLUTIO","NS","ITL",432.87,,"GBP"
"06-03-2011","CURSOL",10067472,"CURSOL","CURRENCY SOLUTIO","NS","ITL",52789.21,,"CAD"
"06-03-2011","SUSAN WILLIAMS",,,,,"BAC",12023.34,,"GBP"
"06-03-2011","CURSOL",10067441,"CURSOL","CURRENCY SOLUTIO","NS","ITL",,705.31,"USD"
"06-03-2011","CURSOL",10167441,"CURSOL","CURRENCY SOLUTIO","NS","ITL",,13159.99,"GBP"
"06-03-2011","JOHN SMITH","CS00001",,,,"BAC",10000,,"GBP"
"06-03-2011","JANE DOE","CS00002",,,,"BAC",42050.12,,"GBP"
"06-03-2011","CURSOL",10067345,"CURSOL","CURRENCY SOLUTIO","NS","ITL",10528.53,,"GBP"
"06-03-2011","JOHN SMITH","CS00001",,,,"BAC",10000,,"GBP"
"06-03-2011","CURSOL",10067345,"CURSOL","CURRENCY SOLUTIO","NS","ITL",,12000,"EUR"
"06-03-2011","CURSOL",10067472,"CURSOL","CURRENCY SOLUTIO","NS","ITL",,33790.08,"GBP"
"06-03-2011","TERRY WHITE",,,,,"ITL",132010.21,,"EUR"
"06-03-2011","JOHN SMITH","CS00001",,,,"BAC",10000,,"GBP"
"06-03-2011","CURSOL",10167441,"CURSOL","CURRENCY SOLUTIO","NS","ITL",21442.89,,"USD"


 * @author <insert name>
 * @package test
class Bootstrap 
    public static function 
        0 Check for arg count. If fails exit w/ error
        1 Get file
        2 read row
            2.1 chk for PAY#######XY
            2.2 DEBIT[$cur] = +DEB
if(count($argv)!=) {
"Usage : php Bootstrap.php statement.csv \n"
$handle fopen("statement.csv""r");
$row_c 0;
$credit_col $curr_col 0;
$output =array();
        while ((
$data fgetcsv($handle5000",")) !== FALSE) {
//$headers_r = explode(';' , $data[0] );                 //old
$headers_r =  $data ;    
//var_dump($headers_r );
$credit_col array_search('Debit',$headers_r) ;
$curr_col array_search('Currency',$headers_r) ;
$credit_col == NULL ) die("No Debit column \n");
$pay_pattern '/PAY\d{6}[A-Z]{2}/i' ;
$lineimplode(';',$data); //exit;
if(preg_match($pay_pattern,$line) ) {
$row explode(';',$line);
$output$row[$curr_col] ] =+ $row[$credit_col] ;    #TODO 
//echo "Count is ", $row_c ,"\n";   
"Totals \n";
$output as $curr => $amt)
$curr,"\t",$amt ,"\n" ;

__Output__ $php Bootstrap.php Usage : php Bootstrap.php statement.csv $php Bootstrap.php statement.csv Totals EUR 43543.23 USD 13432.34 GBP 3432.21 CAD 2321.34 $

Return to Kesavan Muthuvel's home page.

Please send comments on these web pages to (or)  Feedback here

CopyLeft (Ͻ) 2008 - 2015 Kesavan Muthuvel More on CopyLeft

I Don't Love FaceBook