Here is my code,

use DBI;

$dbh = DBI->connect(qq{DBI:CSV:});
$dbh->{'csv_tables'}->{'host'} = {
     'col_names' => ["Id", "Name", "IP", "OS", "VERSION", "ARCH"],
     'sep_char' => "|++|",
     'eol' => "\n",
     'file' => './foo'
      };
my $sth = $dbh->prepare("SELECT * FROM host");
$sth->execute() or die "Cannot execute: " . $sth->errstr();
while (my $row = $sth->fetchrow_hashref) {
   print("Id = ", $row->{'Id'});
   print("\nName=", $row->{'Name'});
   print("\nIP=", $row->{'IP'});
   print("\nOS=", $row->{'OS'});
   print("\nVersion=", $row->{'VERSION'});
   print("\nARCH=", $row->{'ARCH'});
}
$sth->finish();
$dbh->disconnect();

and my data,

100|++|abc|++|1.2.3.4|++|SunOS|++|5.10|++|sparc
101|++|abd|++|1.2.3.5|++|SunOS|++|5.10|++|sparc
102|++|abe|++|1.2.3.6|++|SunOS|++|5.10|++|sparc
103|++|abf|++|1.2.3.7|++|SunOS|++|5.10|++|sparc

Column separator is (|++|) and Line separator is newline (\n)

Thanks
- Santosh

On 4/27/07, Robert Roggenbuck <[EMAIL PROTECTED]> wrote:

Hi,

can You show us a relevant code snippet (connecting and querying) and a
snippet
of Your CSV-Data? Which kind of line separator are You using?

Best Regards

Robert

----

Santosh Pathak schrieb:
> Hi,
>
> I read on following site that DBD::CSV supports multi-character
separator.
> But I am not able to use it. my separator is |++|
> http://www.annocpan.org/~JZUCKER/DBD-CSV-0.22/lib/DBD/CSV.pm<
http://www.annocpan.org/%7EJZUCKER/DBD-CSV-0.22/lib/DBD/CSV.pm>
>
>
> Even after setting sep_char to |++|, it doesn't work.
> Am I missing something?
>
> Thanks
> - Santosh
>

--

===================================================
Robert Roggenbuck, M.A.
Konrad Zuse Zentrum fuer Informationstechnik Berlin
Takustr. 7          D-14195 Berlin
[EMAIL PROTECTED]
http://www.mathematik-21.de/
http://www.zib.de/

Buero:
Universitaet Osnabrueck
Fachbereich Mathematik / Informatik
Albrechtstr. 28a    Fon: ++49 (0)541/969-2735
D-49069 Osnabrueck  Fax: ++49 (0)541/969-2770
http://www.mathematik.uni-osnabrueck.de/
===================================================

Reply via email to