Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
CSVHeaderFile(3)      User Contributed Perl Documentation     CSVHeaderFile(3)

NAME
       IO::CSVHeaderFile - Perl	extension for CSV Files

SYNOPSIS
	 # to read ...
	 use IO::CSVHeaderFile;
	 my $csv = IO::CSVHeaderFile->new( "< $filename" );
	 while(my $hash	= $csv->csv_read ){
	       print "$hash->{ColHeaderTitle}\n";
	 }
	 $csv->close;

	 # or for same named columns
	 my $csv = IO::CSVHeaderFile->new( "< $filename" );
	 my $data;
	 while(@array =	$csv->csv_read ){
	       for(my $i=0; $i<	@array;	$i++) {
		       print "Column '$array[$i]': $array[$i]\n";
	       }
	       print "-- end of	record\n";
	 }
	 $csv->close;

	 # to write ...
	 use IO::CSVHeaderFile;
	 my $csv = IO::CSVHeaderFile->new( "> $filename" ,
	       {col => ['ColHeaderTitle1','ColHeaderTitle2','ColHeaderTitle1'],	noheaders => 1}	);
	   $csv->csv_print({ColHeaderTitle1 => 'First',	ColHeaderTitle2	=> 'Second'}) or return;
	   $csv->csv_print(['Uno', 'Duo', 'Tre']) or return;
	   $csv->csv_print(
	       ColHeaderTitle1 => 'One',
	       ColHeaderTitle2 => 'Two',
	       ColHeaderTitle1 => 'Three with the same name as One'
	       ) or return;
	 $csv->close;

DESCRIPTION
       Read from and write to csv file.

   EXPORT
       None by default.

   FUNCTIONS
       csv_print RECORD	| LIST
	   Store the "RECORD" into file,  "RECORD" can be hash reference as
	   returned from "csv_read" or an array	ref with values	ordered	same
	   as respctive	headers	in file.

	   If LIST variant is used it can be a hash definition like a list in
	   form	of headers and values, but the header names doesn't have to be
	   unique. This	is usefull when	creating a CSV file with several same
	   named columns.

       csv_read
	   Return the next record (hash	reference in scalar context, array of
	   header names	and values in list context) from the file.  Returns
	   "undef" if "eof".

AUTHOR
       Vasek Balcar, <vasek@ti.cz>

SEE ALSO
       IO::File, IO::Handle, perl.

POD ERRORS
       Hey! The	above document had some	coding errors, which are explained
       below:

       Around line 194:
	   You forgot a	'=back'	before '=head1'

perl v5.32.0			  2007-07-06		      CSVHeaderFile(3)

NAME | SYNOPSIS | DESCRIPTION | AUTHOR | SEE ALSO | POD ERRORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=IO::CSVHeaderFile&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help