Import


The import library easily creates model data from common input formats like json, xls, or csv. This can be used for connecting to APIs or for providing file import mechanisms to site administrators.


gdocs_spreadsheet()

Reads a tab of a published Google Document in CSV format returns an array of objects. In order to use this you must make the document publicly available on a link – it is recommended to set it to ‘share with people who have the link’. You may want to unshare the document after an import.

By default, the first tab (sheet) is imported. You can also import any other tab (sheet) of a document. When you select the tab (sheet), the fragment #gid=123 is added to the url. A url with such a fragment will import the selected tab (sheet).

@param string $url A CSV-formatted url. You must share the document publicly in Google docs. If it is a one-time import with sensitive data you should unshare it afterwards.
@param boolean $first_row_is_header If set to true, the values of the first row will be used as keys (converted to compatible chars).
@param string $delimiter Set the field delimiter (one character only).
@param string $enclosure Set the field enclosure character (one character only).
@param string $escape Set the escape character (one character only). Defaults as a backslash.
@return array An array of objects where the keys are either numbers or taken from the header row.

csv()

Reads a CSV document and returns an array of objects.

$this->zajlib->import->csv('file.csv')

@param string $urlORfile A CSV-formatted file (relative to basepath) or URL.
@param boolean $first_row_is_header If set to true, the values of the first row will be used as keys (converted to compatible chars).
@param string $delimiter Set the field delimiter (one character only).
@param string $enclosure Set the field enclosure character (one character only).
@param string $escape Set the escape character (one character only). Defaults as a backslash ().
@return array An array of objects where the keys are either numbers or taken from the header row.

xls()

Reads an Excel document and returns an array of objects.

$this->zajlib->import->xls('file.csv')

@param string $urlORfile A CSV-formatted file (relative to basepath) or URL.
@param boolean $first_row_is_header If set to true, the values of the first row will be used as keys (converted to compatible chars).
@return array An array of objects where the keys are either numbers or taken from the header row.

Outlast Web & Mobile Development (c) 2023 | Privacy Policy |