Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Export CSV v2

by choroba (Cardinal)
on Oct 09, 2012 at 00:52 UTC ( [id://997905]=note: print w/replies, xml ) Need Help??


in reply to Export CSV v2

Have you looked at line 22?
# Get vars from second line my @vars = @{ $csv->getline($csvfh) };
When does getline return an undef? Your input probably contains only one line, already consumed by $columnNames.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Export CSV v2
by Tux (Canon) on Oct 09, 2012 at 07:09 UTC

    If getline () returns undef it has to be end-of-file, because in all other cases auto_diag => 2 will cause a croak (). It is possible to get an empty list there, but that would not result in an error on that point.


    Enjoy, Have FUN! H.Merijn
    pmsig-200365
Re^2: Export CSV v2
by Perl3r (Novice) on Oct 09, 2012 at 01:04 UTC

    Thanks choroba
    Input files contains at the moment 5 lines.. eg

    Location,Router_Name,Loopback IP,OSPF Process ID,OSPF Area,Network,Mas +k,GIG0/0 IP Address,0/0 Subnet Mask,Template ##location##,##rtrname##,##loop0-ip##,##ospf-id##,##ospf-area##,##ospf +-network##,##ospf-mask##,##eth00-ip##,##eth00-sm##, Sydney,SYD-RTR-001,192.168.15.1,99,0,172.25.16.0,0.0.0.255,172.25.16.6 +,255.255.255.0,router-C3840 Canberra,CBR-RTR-001,192.168.15.2,99,0,172.25.16.0,0.0.0.255,172.25.16 +.10,255.255.255.0,router-C2600 Melbourne,MEL-RTR-001,192.168.15.3,99,0,172.25.16.0,0.0.0.255,172.25.1 +6.14,255.255.255.0,router-C3840
      Then you are probably setting the end-of-line to something else than actually present in the data.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Hi,

      I am suspicious of that comma at the end of line 2.

      J.C.

        Sorry, that was an error on my part- there is actually a value there.. Also it makes no difference if there is, or is not a value there. .

        Thanks for looking

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://997905]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found