FileIO
Usage
use FileIO;
or
import FileIO;
- const fioLogger = new Logger(logLevel, logChannel)
- enum FileType { HDF5, ARROW, PARQUET, CSV, UNKNOWN }
- enum constant HDF5
- enum constant ARROW
- enum constant PARQUET
- enum constant CSV
- enum constant UNKNOWN
- proc appendFile(filePath: string, line: string) throws
- proc writeToFile(filePath: string, line: string) throws
- proc writeLinesToFile(filePath: string, lines: string) throws
- proc getLineFromFile(filePath: string, lineIndex: int = -1) : string throws
- proc getLineFromFile(path: string, match: string) throws
- proc delimitedFileToMap(filePath: string, delimiter: string = ", ") : map
- proc initDirectory(filePath: string) throws
- proc ensureClose(tmpf: file) : bool
Ensure the file is closed, disregard errors
- proc isGlobPattern(filename: string) : bool throws
Indicates whether the filename represents a glob expression as opposed to
an specific filename
- proc generateFilenames(prefix: string, extension: string, targetLocalesSize: int) : [] string throws
Generates a list of filenames to be written to based upon a file prefix,
extension, and number of locales.
- proc generateFilename(prefix: string, extension: string, idx: int) : string throws
Generates a file name composed of a prefix, which is a filename provided by
the user along with a file index and extension.
- proc getMatchingFilenames(prefix: string, extension: string) throws
Generates an array of filenames to be matched in APPEND mode and to be
checked in TRUNCATE mode that will warn the user that 1..n files are
being overwritten.
- proc deleteMatchingFilenamesMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab) : MsgTuple throws
Delete files matching a prefix and following the pattern <prefix>_LOCALE*.
- proc deleteMatchingFilenames(prefix: string, extension: string) throws
- proc deleteFile(filename: string) throws
- proc getFileMetadata(filename: string)
Returns a tuple composed of a file prefix and extension to be used to
generate locale-specific filenames to be written to.
- const MAGIC_PARQUET : bytes = b"PAR1"
- const MAGIC_HDF5 : bytes = b"\x89HDF\r\n\x1A\n"
- const MAGIC_ARROW : bytes = b"ARROW1\x00\x00"
- const MAGIC_CSV : bytes = b"**HEADER"
- proc getFileTypeByMagic(header: bytes) : FileType
Determine FileType based on public File Magic for supported types :arg header: file header :type header: bytes
- Returns:
FileType from enum.FileType
- proc domain_intersection(d1: domain(1), d2: domain(1))
- proc getFirstEightBytesFromFile(path: string) : bytes throws
- proc getFileType(filename: string) throws
- proc getFileTypeMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab) : MsgTuple throws
- proc lsAnyMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab) : MsgTuple throws
- proc globExpansionMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab) : MsgTuple throws