CsvFile extends File
Table of Contents
Constants
- APPEND = 1
- BOM_TYPE_UTF8 = ""
- DELIMITER_SPS = ' '
- DELIMITER_TAB = "\t"
- DELIMITER_TZP = ';'
- DELIMITER_ZPT = ','
- ERROR_32K_FIELD_LENGTH = '32k_field_length'
- FIELDS_TYPE_FIXED_WIDTH = 'F'
- FIELDS_TYPE_WITH_DELIMITER = 'R'
- LINE_DELIMITER_UNIX = "\r"
- LINE_DELIMITER_WIN = "\r\n"
- REWRITE = 0
Methods
- __construct() : mixed
- checkUtf8Bom() : bool
- Check UTF-8 Byte-Order Mark
- close() : void
- Closes the file.
- delete() : mixed
- deleteFile() : mixed
- fetch() : array<string|int, mixed>|null
- Fetch data row.
- generateTemporalFile() : static
- Creates temporal file.
- getContents() : mixed
- getContentType() : mixed
- getCreationTime() : mixed
- getDirectory() : mixed
- getDirectoryName() : mixed
- getExtension() : mixed
- getFileContents() : mixed
- getFileSize() : mixed
- getFirstHeader() : bool
- Tells true if first row is a header.
- getLastAccessTime() : mixed
- getModificationTime() : mixed
- getName() : mixed
- getPath() : mixed
- getPermissions() : mixed
- getPhysicalPath() : mixed
- getPos() : int
- Returns reading position.
- getSize() : float|int
- Returns the file size.
- hasUtf8Bom() : bool
- Tells true if UTF Byte-Order Mark exists in the file.
- isDirectory() : mixed
- isExists() : mixed
- isFile() : mixed
- isFileExists() : mixed
- isLink() : mixed
- isReadable() : mixed
- isSystem() : mixed
- isWritable() : mixed
- markWritable() : mixed
- moveFirst() : void
- Moves reading position to the first byte.
- open() : resource
- Opens the file and returns the file pointer.
- openLoad() : bool
- Opens file for reading.
- openWrite() : bool
- Opens file for writing.
- prefaceWithUtf8Bom() : self
- Sets if UTF-8 Byte-Order Mark exists.
- put() : bool
- Writes data fields into file as row.
- putContents() : mixed
- putFileContents() : mixed
- read() : string
- Read file.
- readFile() : mixed
- rename() : mixed
- seek() : int
- Seeks on the file pointer from the beginning (SEEK_SET only).
- setFieldDelimiter() : self
- Sets up delimiter character.
- setFieldsType() : self
- Set fields type.
- setFirstHeader() : self
- Sets first row as a header.
- setPos() : void
- Sets new reading position.
- setRowDelimiter() : self
- Sets up row delimiter character.
- setUtf8Bom() : self
- Sets UTF Byte-Order Mark.
- setWidthMap() : self
- Sets up fields widths.
- write() : int
- Write file.
Constants
APPEND
public
mixed
APPEND
= 1
BOM_TYPE_UTF8
public
mixed
BOM_TYPE_UTF8
= ""
DELIMITER_SPS
public
mixed
DELIMITER_SPS
= ' '
DELIMITER_TAB
public
mixed
DELIMITER_TAB
= "\t"
DELIMITER_TZP
public
mixed
DELIMITER_TZP
= ';'
DELIMITER_ZPT
public
mixed
DELIMITER_ZPT
= ','
ERROR_32K_FIELD_LENGTH
public
mixed
ERROR_32K_FIELD_LENGTH
= '32k_field_length'
FIELDS_TYPE_FIXED_WIDTH
public
mixed
FIELDS_TYPE_FIXED_WIDTH
= 'F'
FIELDS_TYPE_WITH_DELIMITER
public
mixed
FIELDS_TYPE_WITH_DELIMITER
= 'R'
LINE_DELIMITER_UNIX
public
mixed
LINE_DELIMITER_UNIX
= "\r"
LINE_DELIMITER_WIN
public
mixed
LINE_DELIMITER_WIN
= "\r\n"
REWRITE
public
mixed
REWRITE
= 0
Methods
__construct()
public
__construct(mixed $path[, mixed $siteId = null ]) : mixed
Parameters
- $path : mixed
- $siteId : mixed = null
checkUtf8Bom()
Check UTF-8 Byte-Order Mark
public
checkUtf8Bom() : bool
Return values
boolclose()
Closes the file.
public
close() : void
Tags
delete()
public
delete() : mixed
deleteFile()
public
static deleteFile(mixed $path) : mixed
Parameters
- $path : mixed
fetch()
Fetch data row.
public
fetch() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgenerateTemporalFile()
Creates temporal file.
public
static generateTemporalFile(string $prefix[, string $suffix = '.tmp' ][, int $timeToLive = 3 ]) : static
Parameters
- $prefix : string
-
Name prefix.
- $suffix : string = '.tmp'
-
Name suffix.
- $timeToLive : int = 3
-
Hours to keep files alive.
Return values
staticgetContents()
public
getContents() : mixed
getContentType()
public
getContentType() : mixed
getCreationTime()
public
getCreationTime() : mixed
getDirectory()
public
getDirectory() : mixed
getDirectoryName()
public
getDirectoryName() : mixed
getExtension()
public
getExtension() : mixed
getFileContents()
public
static getFileContents(mixed $path) : mixed
Parameters
- $path : mixed
getFileSize()
public
getFileSize() : mixed
Use getSize() instead
getFirstHeader()
Tells true if first row is a header.
public
getFirstHeader() : bool
Return values
boolgetLastAccessTime()
public
getLastAccessTime() : mixed
getModificationTime()
public
getModificationTime() : mixed
getName()
public
getName() : mixed
getPath()
public
getPath() : mixed
getPermissions()
public
getPermissions() : mixed
getPhysicalPath()
public
getPhysicalPath() : mixed
getPos()
Returns reading position.
public
getPos() : int
Return values
intgetSize()
Returns the file size.
public
getSize() : float|int
Tags
Return values
float|inthasUtf8Bom()
Tells true if UTF Byte-Order Mark exists in the file.
public
hasUtf8Bom() : bool
Return values
boolisDirectory()
public
isDirectory() : mixed
isExists()
public
isExists() : mixed
isFile()
public
isFile() : mixed
isFileExists()
public
static isFileExists(mixed $path) : mixed
Parameters
- $path : mixed
isLink()
public
isLink() : mixed
isReadable()
public
isReadable() : mixed
isSystem()
public
isSystem() : mixed
isWritable()
public
isWritable() : mixed
markWritable()
public
markWritable() : mixed
moveFirst()
Moves reading position to the first byte.
public
moveFirst() : void
open()
Opens the file and returns the file pointer.
public
open(string $mode) : resource
Parameters
- $mode : string
Tags
Return values
resourceopenLoad()
Opens file for reading.
public
openLoad() : bool
Return values
boolopenWrite()
Opens file for writing.
public
openWrite([string $mode = MainIOFileStreamOpenMode::WRITE ]) : bool
Parameters
- $mode : string = MainIOFileStreamOpenMode::WRITE
-
File writing mode.
Tags
Return values
boolprefaceWithUtf8Bom()
Sets if UTF-8 Byte-Order Mark exists.
public
prefaceWithUtf8Bom([bool $exists = true ]) : self
Parameters
- $exists : bool = true
-
Flag value to setup.
Return values
selfput()
Writes data fields into file as row.
public
put(array<string|int, mixed> $fields) : bool
Parameters
- $fields : array<string|int, mixed>
-
Data field.
Return values
boolputContents()
public
putContents(mixed $data[, mixed $flags = self::REWRITE ]) : mixed
Parameters
- $data : mixed
- $flags : mixed = self::REWRITE
putFileContents()
public
static putFileContents(mixed $path, mixed $data[, mixed $flags = self::REWRITE ]) : mixed
Parameters
- $path : mixed
- $data : mixed
- $flags : mixed = self::REWRITE
read()
Read file.
public
read(int $length) : string
Parameters
- $length : int
-
Amount bytes to read.
Return values
stringreadFile()
public
readFile() : mixed
rename()
public
rename(mixed $newPath) : mixed
Parameters
- $newPath : mixed
seek()
Seeks on the file pointer from the beginning (SEEK_SET only).
public
seek(int|float $position) : int
Parameters
- $position : int|float
Tags
Return values
intsetFieldDelimiter()
Sets up delimiter character.
public
setFieldDelimiter([string $fieldDelimiter = self::DELIMITER_TZP ]) : self
Parameters
- $fieldDelimiter : string = self::DELIMITER_TZP
-
Char.
Return values
selfsetFieldsType()
Set fields type.
public
setFieldsType([string $fieldsType = self::FIELDS_TYPE_WITH_DELIMITER ]) : self
Parameters
- $fieldsType : string = self::FIELDS_TYPE_WITH_DELIMITER
-
Type.
Return values
selfsetFirstHeader()
Sets first row as a header.
public
setFirstHeader([bool $firstHeader = false ]) : self
Parameters
- $firstHeader : bool = false
-
Flag.
Return values
selfsetPos()
Sets new reading position.
public
setPos([int $position = 0 ]) : void
Parameters
- $position : int = 0
-
Reading position.
setRowDelimiter()
Sets up row delimiter character.
public
setRowDelimiter([string $rowDelimiter = self::LINE_DELIMITER_WIN ]) : self
Parameters
- $rowDelimiter : string = self::LINE_DELIMITER_WIN
-
Char.
Return values
selfsetUtf8Bom()
Sets UTF Byte-Order Mark.
public
setUtf8Bom([string $mark = self::BOM_TYPE_UTF8 ]) : self
Parameters
- $mark : string = self::BOM_TYPE_UTF8
-
BOM mark.
Return values
selfsetWidthMap()
Sets up fields widths.
public
setWidthMap(array<string|int, int> $mapFields) : self
Parameters
- $mapFields : array<string|int, int>
-
Fields widths.
Return values
selfwrite()
Write file.
public
write(string $content) : int
Parameters
- $content : string
-
Data to write.