.. default-domain:: chpl .. module:: FileIO FileIO ====== **Usage** .. code-block:: chapel use FileIO; or .. code-block:: chapel import FileIO; .. data:: const fioLogger = new Logger(logLevel, logChannel) .. enum:: enum FileType { HDF5, ARROW, PARQUET, CSV, UNKNOWN } .. enumconstant:: enum constant HDF5 .. enumconstant:: enum constant ARROW .. enumconstant:: enum constant PARQUET .. enumconstant:: enum constant CSV .. enumconstant:: enum constant UNKNOWN .. function:: proc appendFile(filePath: string, line: string) throws .. function:: proc writeToFile(filePath: string, line: string) throws .. function:: proc writeLinesToFile(filePath: string, lines: string) throws .. function:: proc getLineFromFile(filePath: string, lineIndex: int = -1): string throws .. function:: proc getLineFromFile(path: string, match: string) throws .. function:: proc delimitedFileToMap(filePath: string, delimiter: string = ","): map .. function:: proc initDirectory(filePath: string) throws .. function:: proc ensureClose(tmpf: file): bool * Ensure the file is closed, disregard errors .. function:: proc isGlobPattern(filename: string): bool throws * Indicates whether the filename represents a glob expression as opposed to * an specific filename .. function:: 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. .. function:: 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. .. function:: 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. .. function:: 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. .. data:: const MAGIC_PARQUET: bytes = b"PAR1" .. data:: const MAGIC_HDF5: bytes = b"\x89HDF\r\n\x1A\n" .. data:: const MAGIC_ARROW: bytes = b"ARROW1\x00\x00" .. data:: const MAGIC_CSV: bytes = b"**HEADER" .. function:: 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 .. function:: proc domain_intersection(d1: domain(1), d2: domain(1)) .. function:: proc getFirstEightBytesFromFile(path: string): bytes throws .. function:: proc getFileType(filename: string) throws .. function:: proc getFileTypeMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws .. function:: proc lsAnyMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws .. function:: proc globExpansionMsg(cmd: string, msgArgs: borrowed MessageArgs, st: borrowed SymTab): MsgTuple throws