via_newsgroup
Fri Feb 04 14:22:27 CST 2005
In microsoft.public.money, AngryDeveloper wrote:
>
>By the time I'm done I should no longer be quite as angry and the other
>employees here will be able to use this for either Quicken or Money.
>Ideas and Suggestions appreciated
>AngryDeveloper -- Solving the worlds problems one hack at at time.
You might find a thing I wrote for experimentation of interest.
This was set up as a handler for a datatype QQQ that I made up. The
plan was to save a qif file that was probably in DD/MM/YYYY format
and switch it to MM/DD/YYYY. If the transactions were already
MM/DD/YYYY it would probably leave the data alone. The exception is
that if no DD > 12 with either interpretation, it could not deduce
the existing format, so would just flip it. It was just
experimental. I did not have an actual need.
At the end it sends its munged output on to mnyimprt.exe as a QIF
file. I actually got it to work.
If you were looking for an expedient solution to your problem, you
could just strip entries with date < a parameter. You are looking
beyond expedient.
In Perl, variables need not be declared. Non-array variables start
with "$" and are initially 0 or "" as appropriate.
===============================qifmmdd.pl=========================
#!/usr/bin/perl
#
# This program is completely public domain with no warrantee.
# This program is not hardened against attack and could allow
# hacker access if they got you to import a fake QIF file.
# This relies on Perl being installed on your computer.
# One suitable install is available as ActivePerl from
#
http://activestate.com/Perl.plex In addition, in this file
# a line must be hard modified to match path a on your system.
# That is near the bottom.
# Also, a modified path to perl.exe and this file must be placed in the
# file types for QQQ filetype Open action if you want automatic launch
# from websites.
# $DEBUG variable must be 0 to pass the modified file to mnyimprt.exe.
# 1 or 2 are debug modes.
#
$DEBUG=0;
if ($DEBUG>1)
{ print "Press the Enter key to continue 1\n";
$s=<STDIN>;
}
$srcfile = shift; #read what should be only parameter
if ($DEBUG>0){print "param was \"$srcfile\"\n"}
if (open (SRCFILE, "+<$srcfile"))
{
@line= <SRCFILE>; #read whole file into array
if ($DEBUG>1){print "\$#line=$#line\n"}
for (my $i=0; $i<= $#line; $i++)
{
if ($line[$i] =~ /^D(\d\d)\/(\d\d).*/i)
{
$ff=$1; #first pair of digits
$ss=$2; #second pair of digits
if ($ss>12){$IsMMDD=1} #if first pair big, must be mm/dd/yyyy
file
if ($ff>12){$IsDDMM=1}
if ($DEBUG>1){print "D$ff/$ss found\n"}
}
else {if ($DEBUG>1){print "\$line[$i]=$line[$i]\n"}}
}
# could do more sophisticated test to allow for neither determined
# as it stands, will flip if in doubt.
if ($IsMMDD ){if ($DEBUG){print "File was already MM/DD/YYYY\n"}}
else # gotta flip DD with MM
{
#reset file pointer.
close SRCFILE;
open (SRCFILE, ">$srcfile")||die "Can't reopen $srcfile\n";
for (my $i=0; $i<= $#line; $i++)
{
if ($line[$i] =~ /^D(\d\d)\/(\d\d)(.*)/i)
{
#$ff=$1; #first pair of digits
#$ss=$2; $second pair of digits
if ($DEBUG){print "D$2/$1$3"}
print SRCFILE "D$2/$1$3\n";
}
else
{
print SRCFILE $line[$i];
}
}
}
}
else
{
print "could not open \"$srcfile\"\n";
}
# ***** must modify string to match your path to mnyimprt.exe.
$cmd1=
"\"C:\\Program Files\\Microsoft Money
2005\\MNYCoreFiles\\mnyimprt.exe\"".
" $srcfile";
if ($DEBUG)
{
print "\$cmd1=$cmd1\n";
print "Press the Enter key to continue\n";
$s=<STDIN>;
}
else #not DEBUG
{
$res1=system ($cmd1);
if ($res1)
{
print "\$cmd1=$cmd1\n";
print "command failed. result result was $res1\n";
die "aborting\n";
}
}