ePages 6.11.0 - DE_EPAGES/Core/API/CSV/BaseImportHandler.pm

Package DE_EPAGES::Core::API::CSV::BaseImportHandler

Base class for csv import drivers

Functions

converter
drive
encodeFrom
fileHandle
fileName
header
importCSV
importLine
incLineNumber
lineNumber
linesCount
new
parse
popID
pushID
readHeader
readLine
readLines
topID
useBOM

converter

return the current csv converter

Syntax
$converter = $self->converter;
Return
$converter

drive

read the data content lines, uses function readLines

Syntax
$self->drive();

encodeFrom

returns the target encoding (was set in exportCSV)

Syntax
encodeFrom();
Example
$Driver->encodeFrom();
Return
$Encoding (string)
target encoding (utf8,iso-8859-1,...)

fileHandle

return the current fileHandle

Syntax
$self->fileHandle;
Return
$FileHandle (filehandle)
setted by exportCSV

fileName

return the current fileName

Syntax
$self->fileName;
Return
$FileName (string)
export file name

header

return the header columns

Syntax
$self->header;
Return
$Header (ref.array.string)
header columns

importCSV

imports data (2 dim. array) from a file. opens the document, calls function setLinesCount, calls function parse and closes the document

Syntax
$Package->importCSV($FileName, $hFormat);
Input
$FileName (string)
export file
$hFormat (ref.hash)
export file format
  • eol - end of line (optional, default: "\n")
  • encoding - character encoding (optional, default: "iso-8859-1")
  • quote_char - field delimiter (optional, default: '"')
  • escape_char - escape character (optional, default: '"')
  • sep_char - field separator (optional, default: ",")
Return
$Importer (object)
importer

importLine

imports one data line, get the line element from function topID('Item') this is only a dummy funtion here.

Syntax
$self->importLine();

incLineNumber

increments the line number and returns the new number

Syntax
$linenumber = $self->incLineNumber;
Return
$linenumber (integer)
current line number

lineNumber

return the current linenumber

Syntax
$linenumber = $self->lineNumber;
Return
$linenumber (integer)
current line number

linesCount

return the count of lines of current fileHandle

Syntax
$self->linesCount;
Return
$LinesCount (integer)
set by setLinesCount

new

create a new csv import handler

Syntax
$Handler = DE_EPAGES::Core::API::CSV::BaseImportHandler->new(%options);
Input
%options (hash)
importer options
Return
$Handler (object)
importer

parse

reads the header via function readHeader, calls function drive

Syntax
$self->parse();

popID

removes a parameter from the parameter stack and returns its value.

Syntax
$Value = $self->popID( $Key );
Example
$CompanyID = $self->popID( 'CompanyID' );
Input
$Key (string)
parameter name
Return
(parameter value)
$Value

pushID

adds a parameter to the parameter stack. Any previous parameter with the same name will be hidden until $self->popID( $Key ) is called. Use $self->topID( $Key ) to get the parameter value. Use $self->popID( $Key ) to remove the parameter from the stack.

Syntax
$self->pushID( $Key, $Value );
Example
$self->pushID( 'CompanyID', $CompanyID );
Input
$Key (string)
parameter name
$Value
parameter value

readHeader

read the header

Syntax
$self->readHeader();

readLine

imports a line ( reads and converts from the filehandle )

Syntax
$aLineElements = $self->readLine;
Return
$aLineElements (ref.array.string)
list of values or undef on end of file

readLines

reads the content lines via function readLine, calls for each line function importLine

Syntax
$self->readLines();

topID

returns the current value of a parameter

Syntax
$Value = $self->topID( $Key );
Example
$CompanyID = $self->topID( 'CompanyID' );
Input
$Key (string)
parameter name
Return
(parameter value)
$Value

useBOM

returns true if the file has a Unicode Byte Order Mark

Syntax
$UseBPM = $Driver->useBOM;
Return
$UseBPM (boolean)
true if the file has a Unicode Byte Order Mark