Cybershmuck
Technical User
- Jan 21, 2005
- 21
Hi,
I’ve got a CSV file with the following information that I want to cycle through each line and split the values up by commas. The first line is the header record
BSB,Account Number, Amount (Gross),Account Name,Memo
62919,10213139,$203.40,A Wiesner,
112879,121473373,$125.55,AJ Bagala,
244000,106685045,"$7,605.40",Dell Australia Pty Ltd,
83091,466155928,$287.10,Digiguard.net Pty Ltd,
,,
,,
,,
How do I skip lines with blanks and how do I strip off trailing commas of each record?
Here’s my attempt of the code:
Thanks in advance
I’ve got a CSV file with the following information that I want to cycle through each line and split the values up by commas. The first line is the header record
BSB,Account Number, Amount (Gross),Account Name,Memo
62919,10213139,$203.40,A Wiesner,
112879,121473373,$125.55,AJ Bagala,
244000,106685045,"$7,605.40",Dell Australia Pty Ltd,
83091,466155928,$287.10,Digiguard.net Pty Ltd,
,,
,,
,,
How do I skip lines with blanks and how do I strip off trailing commas of each record?
Here’s my attempt of the code:
Code:
my $fieldnames = 1;
my $header = <IN> if $fieldnames;
@data = <IN>;
foreach my $currentline (@data)
{
#Need some code her to strip off trailing commas
next if (index($currentline, ",,") > -1); #Skip any lines with just ,, in it
($bsb, $acct_num, $amt, $acct_name, $memo) = split /,/,
$currentline;
Thanks in advance