creating QIF file under Dos using AWK
Edward Doolittle
edward.doolittle at gmail.com
Wed Mar 18 18:04:41 EDT 2015
If you want to throw away the first row, the simplest way would be
$csv->getline($fh); just before $csv->column_names(...) . The first getline
would then get a line from the file and just throw it away with no other
effect than moving to the next record in the input file.
To make the script a little more robust (if the bank should ever stop
putting the BANK EXPORT;;; row in), you could try something like if
($csv->getline($fh)->[0] !~ m/BANK EXPORT/) die "Unexpected first row"; I
haven't tested it though.
On 18 March 2015 at 04:23, piggyb <piggybattery at gmail.com> wrote:
> With the help of Google I have created this Perl script #!/usr/bin/perl
> use
> strict; use warnings; use Text::CSV; my $file = "input.csv"; open my
> $fh,
> "<", $file or die "$file: $!"; my $csv = Text::CSV->new ({ binary => 1,
> auto_diag => 1,sep_char => ";" }); $csv->column_names ($csv->getline
> ($fh)); # use header print "!Type:Bank\n"; while (my $row =
> $csv->getline_hr ($fh)) { my $CreditDebet = $row->{CreditDebet};
> print "D".$row->{TransactionDate}."\n"; if ( $CreditDebet eq
> "C"){ print "T".$row->{Amount}."\n";
> }
> elsif ( $CreditDebet eq "D"){ print
> "T-".$row->{Amount}."\n";
> } print "M".$row->{Disciption}."\n" print
> "N".$row->{PayMethode}."\n"; print
> "P".$row->{CounterNumber}."\n";
> print "A".$row->{Adress}."\n"; print "^\n"; } close
> $fh; But
> how can I tell the script that the second row contains the headers? The
> first row starts with BANK EXPORT;;;;;;;;;;;;;;
>
>
>
> --
> View this message in context:
> http://gnucash.1415818.n4.nabble.com/creating-QIF-file-under-Dos-using-AWK-tp4676673p4676996.html
> Sent from the GnuCash - User mailing list archive at Nabble.com.
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
>
--
Edward Doolittle
Associate Professor of Mathematics
First Nations University of Canada
1 First Nations Way, Regina SK S4S 7K2
« Toutes les fois que je donne une place vacante, je fais cent mécontents
et un ingrat. »
-- Louis XIV, dans Voltaire, Le Siècle de Louis XIV, Chap. XXVI
More information about the gnucash-user
mailing list