Skip to main content
FiQueLa supports nine file formats through dedicated stream classes. Each format is identified by a short key used in FQL syntax and in the Enum\Format enum.

Format table

KeyNameClassFileString
csvCSVFQL\Stream\CsvYesNo
xmlXMLFQL\Stream\XmlYesNo
xlsXLS / XLSXFQL\Stream\XlsYesNo
odsODSFQL\Stream\OdsYesNo
jsonFileJSON streamFQL\Stream\JsonStreamYesNo
ndJsonNewline-delimited JSONFQL\Stream\NDJsonYesNo
jsonJSON (json_decode)FQL\Stream\JsonYesYes
yamlYAMLFQL\Stream\YamlYesYes
neonNEONFQL\Stream\NeonYesYes
json, yaml, and neon also accept raw strings via Stream\Provider::fromString(). All other formats require a file path.

Opening formats

You can open any format in three ways:
  1. Stream\Provider::fromFile() — auto-detects format from the file extension, or accepts an explicit Enum\Format.
  2. Direct class open() — call the class for the specific format directly.
  3. FQL string syntax — embed the format and path in an FQL FROM clause.
use FQL\Enum\Format;
use FQL\Stream;

// Auto-detect from extension
$csv = Stream\Provider::fromFile('products.csv');

// Explicit format
$csv = Stream\Provider::fromFile('data.txt', Format::CSV);

// Direct class
$csv = Stream\Csv::open('products.csv');

// With custom delimiter
$csv = Stream\Csv::openWithDelimiter('products.csv', ';');

$query = $csv->query()->selectAll()->from('*');
CSV supports two format-specific parameters: encoding (default utf-8) and delimiter (default ,). Pass them via the FQL string syntax: csv(data.csv, "windows-1250", ";").

Format-specific parameters

Only CSV and XML accept additional configuration parameters.

CSV parameters

ParameterDefaultDescription
encodingutf-8Input file encoding. Any encoding accepted by iconv.
delimiter,Single-character field separator.
useHeader11 to treat the first row as column headers, 0 otherwise.
In FQL string syntax:
-- Positional
FROM csv(data.csv, "windows-1250", ";")

-- Named
FROM csv(data.csv, encoding: "windows-1250", delimiter: ";")

XML parameters

ParameterDefaultDescription
encodingutf-8Input file encoding.
In FQL string syntax:
FROM xml(feed.xml, "windows-1250")

Directory provider

FQL\Stream\Dir is a special provider that treats a directory as its data source. It lets you query metadata about files recursively across a directory tree.
use FQL\Stream;

$dir = Stream\Dir::open('./data');

$query = $dir->query()
    ->selectAll()
    ->from('*');
In FQL string syntax, use the dir format key:
SELECT *
FROM dir(./data).*