class TXT (View source)

The GenericDatabase\Helpers\Parsers\TXT class provides methods for parsing, analyzing, and writing TXT and CSV files.

Main funcionalities:

  • Checks if all columns in the given data are null
  • Uses the structure method to generate the schema information
  • Analyze method to determine the column types.

Methods:

  • allColumnsNull($data): Checks if all columns in the given data are null.
  • parse($filePath): Parses a CSV file at the given file path and returns an array of data.
  • analyze($data): Analyzes the given data and returns an array of column types (e.g., integer, float, datetime, string).
  • structure($filePath, $separator): Returns an array of schema information for CSV files in the given folder path, using the given separator.
  • write($overwrite = false): Writes schema information to a file named "Schemas.ini" in the folder path, overwriting the file if specified.

Methods

static array
parse(string $filePath)

Parses a CSV file and returns its data as an array.

static array
structure(string $filePath, string $separator)

Generates the structure of the CSV files in the specified folder.

static void
write(bool $overwrite = false)

Writes the schema information to a Schemas.ini file.

Details

static array parse(string $filePath)

Parses a CSV file and returns its data as an array.

Parameters

string $filePath

The path to the CSV file.

Return Value

array

The parsed data.

static array structure(string $filePath, string $separator)

Generates the structure of the CSV files in the specified folder.

Parameters

string $filePath

The path to the folder containing CSV files.

string $separator

The separator used in the CSV files.

Return Value

array

An associative array where keys are file names and values are arrays of column schemas.

static void write(bool $overwrite = false)

Writes the schema information to a Schemas.ini file.

Parameters

bool $overwrite

Whether to overwrite the existing Schemas.ini file.

Return Value

void