Bitrix API

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
bool

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>|null

generateTemporalFile()

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
static

getContents()

public getContents() : mixed

getContentType()

public getContentType() : mixed

getCreationTime()

public getCreationTime() : 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
bool

getLastAccessTime()

public getLastAccessTime() : mixed

getModificationTime()

public getModificationTime() : mixed

getPermissions()

public getPermissions() : mixed

getPos()

Returns reading position.

public getPos() : int
Return values
int

hasUtf8Bom()

Tells true if UTF Byte-Order Mark exists in the file.

public hasUtf8Bom() : bool
Return values
bool

isExists()

public isExists() : mixed

isFileExists()

public static isFileExists(mixed $path) : mixed
Parameters
$path : mixed

isReadable()

public isReadable() : 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
throws
FileOpenException
Return values
resource

openLoad()

Opens file for reading.

public openLoad() : bool
Return values
bool

openWrite()

Opens file for writing.

public openWrite([string $mode = MainIOFileStreamOpenMode::WRITE ]) : bool
Parameters
$mode : string = MainIOFileStreamOpenMode::WRITE

File writing mode.

Tags
see
FileStreamOpenMode
Return values
bool

prefaceWithUtf8Bom()

Sets if UTF-8 Byte-Order Mark exists.

public prefaceWithUtf8Bom([bool $exists = true ]) : self
Parameters
$exists : bool = true

Flag value to setup.

Return values
self

put()

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
bool

putContents()

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
string

readFile()

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
throws
FileNotOpenedException
Return values
int

setFieldDelimiter()

Sets up delimiter character.

public setFieldDelimiter([string $fieldDelimiter = self::DELIMITER_TZP ]) : self
Parameters
$fieldDelimiter : string = self::DELIMITER_TZP

Char.

Return values
self

setFieldsType()

Set fields type.

public setFieldsType([string $fieldsType = self::FIELDS_TYPE_WITH_DELIMITER ]) : self
Parameters
$fieldsType : string = self::FIELDS_TYPE_WITH_DELIMITER

Type.

Return values
self

setFirstHeader()

Sets first row as a header.

public setFirstHeader([bool $firstHeader = false ]) : self
Parameters
$firstHeader : bool = false

Flag.

Return values
self

setPos()

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
self

setUtf8Bom()

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
self

setWidthMap()

Sets up fields widths.

public setWidthMap(array<string|int, int> $mapFields) : self
Parameters
$mapFields : array<string|int, int>

Fields widths.

Return values
self

        
On this page

Search results