外观
lib-io 库参考
原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793554370/FIN+5.3.1+lib-io 中文整理基于 FIN 5.3.1
导读: 输入/输出函数库
以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。
目录(导读)
- lib
- meta
- docs
- funcs
- Overview
- IO Handles
- FTP Handles
- Examples
- ioAppend(handle)
- ioCharset(handle, charset)
- ioCopy(from, to, opts: {})
- ioCrc(handle, algorithm)
- ioCreate(handle)
- ioDelete(handle)
- ioDigest(handle, algorithm)
- ioDir(handle)
- ioEachCsv(handle, opts, fn)
- ioEachLine(handle, fn)
- ioExport(req, handle)
- ioFromBase64(s)
- ioGzip(handle)
- ioHmac(handle, algorithm, key)
- ioInfo(handle)
- ioMove(from, to)
- ioPbk(algorithm, password, salt, iterations, keyLen)
- ioRandom(size)
- ioReadCsv(handle, opts: null)
- ioReadJson(handle, opts: null)
- ioReadJsonGrid(handle, opts: null)
- ioReadLines(handle, opts: null)
- ioReadStr(handle)
- ioReadTrio(handle)
- ioReadXeto(handle, opts: null)
- ioReadZinc(handle)
- ioSkip(handle, opts)
- ioStreamCsv(handle, opts: null)
- ioStreamLines(handle)
- ioToBase64(handle, opts: null)
- ioToHex(handle)
- ioWriteCsv(val, handle, opts: null)
- ioWriteExcel(val, handle)
- ioWriteHtml(val, handle, opts: {})
- ioWriteJson(val, handle, opts: null)
- ioWriteJsonLd(val, handle)
- ioWriteLines(lines, handle)
- ioWritePdf(val, handle, opts: {})
- ioWriteStr(str, handle)
- ioWriteSvg(val, handle, opts: {})
- ioWriteTrio(val, handle, opts: null)
- ioWriteTurtle(val, handle)
- ioWriteXeto(val, handle, opts: null)
- ioWriteXml(val, handle)
- ioWriteZinc(val, handle)
- ioZipDir(handle)
- ioZipEntry(handle, path)
概述(中译)
输入/输出函数库
API 正文(英文)
docs
Overview • IO Handles • Examples
funcs
| ioAppend | Convert a handle to append mode |
| ioCharset | Configure an I/O handle to use the specified charset |
| ioCopy | Copy a file or directory to the new specified location |
| ioCrc | Generate a cycle reduancy check code as a Number |
| ioCreate | Create a directory or empty file with the given I/O handle |
| ioDelete | Delete a file or a directory as mapped by the given I/O handle |
| ioDigest | Generate a one-way hash of the given I/O handle |
| ioDir | Read a directory listing, return a grid with cols |
| ioEachCsv | Iterate the rows of a CSV file (comma separated values) and callback the given function with two parameters |
| ioEachLine | For each line of the given source stream call the given function with two parameters |
| ioExport | Export a view to the given file handle - see Export |
| ioFromBase64 | Return an I/O handle to decode from a base64 string |
| ioGzip | Wrap an I/O handle to GZIP compress/uncompress |
| ioHmac | Generate an HMAC message authentication as specified by RFC 2104 |
| ioInfo | Get information about a file handle and return a Dict with the same tags as ioDir() |
| ioMove | Move or rename a file or directory |
| ioPbk | Generate a password based cryptographic key |
| ioRandom | Generate randomized series of bytes which can be used as an input I/O handle |
| ioReadCsv | Read a CSV (comma separated values) file into memory as a Grid |
| ioReadJson | Read a JSON file into memory |
| ioReadJsonGrid | Read a JSON file formatted as a standardized Haystack grid into memory |
| ioReadLines | Read an I/O handle into memory as a list of string lines |
| ioReadStr | Read an I/O handle into memory as a string |
| ioReadTrio | Read a Trio file into memory as a list of Dicts |
| ioReadXeto | Read a Xeto data file into memory as a Haystack data type |
| ioReadZinc | Read a Zinc file into memory as a Haystack data type |
| ioSkip | Apply a skipping operation to an input I/O handle |
| ioStreamCsv | Read a stream of dicts from a comma separated value file |
| ioStreamLines | Read a stream of lines |
| ioToBase64 | Encode an I/O handle into a base64 string |
| ioToHex | Encode an I/O handle into hexidecimal string |
| ioWriteCsv | Write a grid to a CSV (comma separated values) file |
| ioWriteExcel | Write an Excel XLS file, where val may be |
| ioWriteHtml | Write an Axon data structure to HTML |
| ioWriteJson | Write an Axon data structure to JSON |
| ioWriteJsonLd | Write an Axon data structure to RDF JSON-LD format |
| ioWriteLines | Write a list of string lines separated with "\n" character |
| ioWritePdf | Render data to a PDF file |
| ioWriteStr | Write a string to an I/O handle |
| ioWriteSvg | Render data to an SVG file |
| ioWriteTrio | Write dicts to a Trio file |
| ioWriteTurtle | Write an Axon data structure to RDF Turtle format |
| ioWriteXeto | Write value to a Xeto text format file |
| ioWriteXml | Write a grid to an XML file |
| ioWriteZinc | Write a Grid to the Zinc format |
| ioZipDir | Read a zip file's entry listing, return a grid with cols |
| ioZipEntry | Return a I/O handle which may be used to read from a zip entry within a zip file |
lib io
Overview
The ioExt is used to read/write data via a variety of formats:
- Text strings:
ioReadStr(),ioWriteStr() - Text lines:
ioReadLines(),ioWriteLines() - Zinc:
ioReadZinc(),ioWriteZinc() - Trio:
ioReadTrio(),ioWriteTrio() - CSV:
ioReadCsv(),ioWriteCsv(),ioEachCsv(),ioStreamCsv() - JSON:
ioReadJson(),ioWriteJson() - XML:
ioWriteXml(),xmlRead() - PDF:
ioWritePdf() - SVG:
ioWriteSvg() - HTML:
ioWriteHtml() - RDF:
ioWriteTurtle(),ioWriteJsonLd()
IO Handles
All the read/write functions take an IO handle which is one of the following:
- any string can be used by the the read functions; if used for a write function then the output is concatenated to the end of the string and returned as the result of the write function
- Uri which starts with "io/" which read/writes relative to the project's io directory
- Uri with
fan://scheme will read files bundled in pods - Uri with
http://orhttps://scheme will read using HTTP GET request (readonly) - Uri with
ftp://orftps://scheme will retreive using FTP - any Dict can be used as an IOHandle. Data will be stored in Folio keyed off the
idof the rec. The data will be removed when the rec is deleted from folio.
The default charset used by all I/O handles is "UTF-8". You can wrap any of the handles above with the ioCharset() function to specify an alternate charset.
FTP Handles
You may read and write files to a FTP server via a ftp:// or ftps:// Uri. Using ioDir() is supported if Uri ends with a slash, but returns name only (not dir, size, or mod). By default the "anonymous" user account is used. But you can customize this by creating a key/value the password manager where the key is the base URI and the value is a string formatted as "user:pass". For example given:
uri: ftp://somehost/somefile.csv
user: bob
pass: secretYou can setup the password for all FTP request to "ftp://somehost/" like this:
passwordSet("ftp://somehost/", "bob:secret")Note that the URI key must end with a slash and match the scheme (ftp or ftps).
In newer versions of Java, you may see the following warning in the console the first time an FTPS connection is made:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by fan.ftp.FtpClientPeer (file:) to field sun.security.ssl.SSLSessionContextImpl.sessionHostPortCache
WARNING: Please consider reporting this to the maintainers of fan.ftp.FtpClientPeer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future releaseIf you see this, then you need to edit your etc/sys/config.props and add the following options to the java.options along with any other options you have set (e.g. heap configuration).
java.options=--add-opens java.base/sun.security.ssl=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMEDExamples
Here are some basic examples:
// export your sites to a trio file: {proj}/io/sites.trio
readAll(site).ioWriteTrio(`io/sites.trio`)
// export your sites to a trio string literal
readAll(site).ioWriteTrio("")
// export point to CSV file
read(weatherTemp).hisRead(pastMonth).ioWriteCsv(`io/point.csv`)
// import history data from CSV file where timestamps
// are formatted as 2010-10-02T13:00
ioReadCsv(`io/his.csv`)
.map(row => {ts: parseDateTime(row->ts, "YYYY-MM-DD'T'hh:mm", "New_York"),
val: parseNumber(row->val)})
.hisWrite(hisId)
// parse an oBIX XML document and map into name/value pairs
xmlRead(`http://obix.acme.com/obix/about`).xmlElems
.map(x => {name:x.xmlAttr("name").xmlVal, val:x.xmlAttr("val").xmlVal})def
func:ioAppend
ioAppend(handle)
Convert a handle to append mode. Writes will append to the end of the file instead of rewriting the file. Raises UnsupportedErr if the handle doesn't support append mode.
Example:
ioWriteStr("append a line\n", ioAppend(`io/foo.txt`))meta
| admin | ✓ |
| def | func:ioAppend |
| is | func |
| lib | lib:io |
| name | ioAppend |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioCharset
ioCharset(handle, charset)
Configure an I/O handle to use the specified charset. The handle is any supported I/O handle and the charset is a string name supported by the JVM installation. Standard charset names:
- "UTF-8" 8-bit Unicode Transformation Format
- "UTF-16BE": 16 bit Big Endian Unicode Transformation Format
- "UTF-16LE" 16 bit Little Endian Unicode Transformation Format
- "ISO-8859-1": Latin-1 code block
- "US-ASCII": 7-bit ASCII
Examples:
// write text file in UTF-16BE
ioWriteStr(str, ioCharset(`io/foo.txt`, "UTF-16BE"))
// read CSV file in ISO-8859-1
ioCharset(`io/foo.csv`, "ISO-8859-1").ioReadCsvmeta
| admin | ✓ |
| def | func:ioCharset |
| is | func |
| lib | lib:io |
| name | ioCharset |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioCopy
ioCopy(from, to, opts: {})
Copy a file or directory to the new specified location. If this file represents a directory, then it recursively copies the entire directory tree. Both handles must reference a local file or directory on the file system.
If during the copy, an existing file of the same name is found, then the "overwrite" option should be to marker or true to overwrite or false to skip. Or if overwrite is not defined then an IOErr is raised.
Examples:
ioCopy(`io/dir/`, `io/dir-copy/`)
ioCopy(`io/file.txt`, `io/file-copy.txt`)
ioCopy(`io/file.txt`, `io/file-copy.txt`, {overwrite})
ioCopy(`io/file.txt`, `io/file-copy.txt`, {overwrite:false})meta
| admin | ✓ |
| def | func:ioCopy |
| is | func |
| lib | lib:io |
| name | ioCopy |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioCrc
ioCrc(handle, algorithm)
Generate a cycle reduancy check code as a Number. See Buf.crc for available algorithms.
Example:
ioCrc("foo", "CRC-32").toHexmeta
| admin | ✓ |
| def | func:ioCrc |
| is | func |
| lib | lib:io |
| name | ioCrc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioCreate
ioCreate(handle)
Create a directory or empty file with the given I/O handle. If creating a file that already exists, it is overwritten as empty.
Examples:
ioCreate(`io/new-dir/`) // create new empty directory
ioCreate(`io/new-file.txt`) // create new empty filemeta
| admin | ✓ |
| def | func:ioCreate |
| is | func |
| lib | lib:io |
| name | ioCreate |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioDelete
ioDelete(handle)
Delete a file or a directory as mapped by the given I/O handle. If a directory is specified, then it is recursively deleted. If the I/O handle does map to a file system then raise exception. If the file does not exist then no action is taken.
meta
| admin | ✓ |
| def | func:ioDelete |
| is | func |
| lib | lib:io |
| name | ioDelete |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioDigest
ioDigest(handle, algorithm)
Generate a one-way hash of the given I/O handle. See Buf.toDigest for available algorithms.
Example:
ioDigest("foo", "SHA-1").ioToBase64meta
| admin | ✓ |
| def | func:ioDigest |
| is | func |
| lib | lib:io |
| name | ioDigest |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioDir
ioDir(handle)
Read a directory listing, return a grid with cols:
uri: Uri for handle to read/write the filename: filename stringmimeType: file mime type or null if unknowndir: marker if file is a sub-directory or nullsize: size of file in bytes or nullmod: modified timestamp or null if unknown
If the I/O handle does not map to a file in the virtual file system then throw an exception.
ioDir(`io/`) // read files in project's io/ directory
ioDir(`fan://haystack`) // read files in podmeta
| admin | ✓ |
| def | func:ioDir |
| is | func |
| lib | lib:io |
| name | ioDir |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioEachCsv
ioEachCsv(handle, opts, fn)
Iterate the rows of a CSV file (comma separated values) and callback the given function with two parameters: Str[] cells of current row and zero based Number line number.
The following options are supported:
- delimiter: separator char as string, default is ","
Also ioReadCsv(), ioWriteCsv(), and CSV.
meta
| admin | ✓ |
| def | func:ioEachCsv |
| is | func |
| lib | lib:io |
| name | ioEachCsv |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioEachLine
ioEachLine(handle, fn)
For each line of the given source stream call the given function with two parameters: Str line and zero based Number line number. Lines are processed according to InStream.eachLine.
meta
| admin | ✓ |
| def | func:ioEachLine |
| is | func |
| lib | lib:io |
| name | ioEachLine |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioExport
ioExport(req, handle)
Export a view to the given file handle - see Export.
Note: this feature is available in SkySpark only
meta
| admin | ✓ |
| def | func:ioExport |
| is | func |
| lib | lib:io |
| name | ioExport |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioFromBase64
ioFromBase64(s)
Return an I/O handle to decode from a base64 string. Also see ioToBase64() and Buf.fromBase64
Example:
// decode base64 to a string
ioFromBase64("c2t5c3Bhcms").ioReadStrmeta
| admin | ✓ |
| def | func:ioFromBase64 |
| is | func |
| lib | lib:io |
| name | ioFromBase64 |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioGzip
ioGzip(handle)
Wrap an I/O handle to GZIP compress/uncompress.
Example:
// generate GZIP CSV file
readAll(site).ioWriteCsv(ioGzip(`io/sites.gz`))
// read GZIP CSV file
ioGzip(`io/sites.gz`).ioReadCsvmeta
| admin | ✓ |
| def | func:ioGzip |
| is | func |
| lib | lib:io |
| name | ioGzip |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioHmac
ioHmac(handle, algorithm, key)
Generate an HMAC message authentication as specified by RFC 2104. See Buf.hmac.
Example:
ioHmac("foo", "SHA-1", "secret").ioToBase64meta
| admin | ✓ |
| def | func:ioHmac |
| is | func |
| lib | lib:io |
| name | ioHmac |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioInfo
ioInfo(handle)
Get information about a file handle and return a Dict with the same tags as ioDir().
If the I/O handle does not map to a file in the virtual file system then throw an exception.
ioInfo(`io/`) // read file info for the project's io/ directory
ioInfo(`io/sites.trio`) // read file info for the io/sites.trio filemeta
| admin | ✓ |
| def | func:ioInfo |
| is | func |
| lib | lib:io |
| name | ioInfo |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioMove
ioMove(from, to)
Move or rename a file or directory. Both handles must reference a local file or directory on the file system. If the target file already exists then raise an IOErr.
meta
| admin | ✓ |
| def | func:ioMove |
| is | func |
| lib | lib:io |
| name | ioMove |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioPbk
ioPbk(algorithm, password, salt, iterations, keyLen)
Generate a password based cryptographic key. See Buf.pbk.
Example:
ioPbk("PBKDF2WithHmacSHA1", "secret", ioRandom(64), 1000, 20).ioToBase64meta
| admin | ✓ |
| def | func:ioPbk |
| is | func |
| lib | lib:io |
| name | ioPbk |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioRandom
ioRandom(size)
Generate randomized series of bytes which can be used as an input I/O handle.
meta
| admin | ✓ |
| def | func:ioRandom |
| is | func |
| lib | lib:io |
| name | ioRandom |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadCsv
ioReadCsv(handle, opts: null)
Read a CSV (comma separated values) file into memory as a Grid. CSV format is implemented as specified by RFC 4180:
- rows are delimited by a newline
- cells are separated by
delimiterchar - cells containing the delimiter,
"double quote, or newline are quoted; quotes are escaped as"" - empty cells are normalized into null
The following options are supported:
- delimiter: separator char as string, default is ","
- noHeader: if present then don't treat first row as col names, instead use "v0", "v1", etc
Also see ioStreamCsv(), ioEachCsv(), ioWriteCsv(), and CSV.
meta
| admin | ✓ |
| def | func:ioReadCsv |
| is | func |
| lib | lib:io |
| name | ioReadCsv |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadJson
ioReadJson(handle, opts: null)
Read a JSON file into memory. This function can used to read any arbitrary JSON nested object/array structure which can be accessed as Axon dicts/lists. The default decoding assumes Haystack 4 JSON format (Hayson). Also see ioReadJsonGrid() if reading a Haystack formatted grid.
Object keys which are not valid tag names will decode correctly and can be used in-process. But they will not serialize correctly over the HTTP API. You can use the safeNames option to force object keys to be safe tag names (but you will lose the original key names).
The following options are supported:
- v3: decode the JSON as Haystack 3
- v4: explicitly request Haystack 4 decoding (default)
- safeNames: convert object keys to safe tag names
meta
| admin | ✓ |
| def | func:ioReadJson |
| is | func |
| lib | lib:io |
| name | ioReadJson |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadJsonGrid
ioReadJsonGrid(handle, opts: null)
Read a JSON file formatted as a standardized Haystack grid into memory. See ioReadJson() to read arbitrary JSON structured data.
meta
| admin | ✓ |
| def | func:ioReadJsonGrid |
| is | func |
| lib | lib:io |
| name | ioReadJsonGrid |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadLines
ioReadLines(handle, opts: null)
Read an I/O handle into memory as a list of string lines. Lines are processed according to InStream.readLine semanatics.
By default the maximum line size read is 4kb of Unicode characters (not bytes). This limit may be overridden using the option key "limit".
Examples:
ioReadLines(`io/file.txt`)
ioReadLines(`io/file.txt`, {limit: 10_000})meta
| admin | ✓ |
| def | func:ioReadLines |
| is | func |
| lib | lib:io |
| name | ioReadLines |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadStr
ioReadStr(handle)
Read an I/O handle into memory as a string. Newlines are always normalized into "\n" characters.
meta
| admin | ✓ |
| def | func:ioReadStr |
| is | func |
| lib | lib:io |
| name | ioReadStr |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadTrio
ioReadTrio(handle)
Read a Trio file into memory as a list of Dicts.
meta
| admin | ✓ |
| def | func:ioReadTrio |
| is | func |
| lib | lib:io |
| name | ioReadTrio |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadXeto
ioReadXeto(handle, opts: null)
Read a Xeto data file into memory as a Haystack data type. See LibNamespace.compileData for details and options.
meta
| admin | ✓ |
| def | func:ioReadXeto |
| is | func |
| lib | lib:io |
| name | ioReadXeto |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioReadZinc
ioReadZinc(handle)
Read a Zinc file into memory as a Haystack data type.
meta
| admin | ✓ |
| def | func:ioReadZinc |
| is | func |
| lib | lib:io |
| name | ioReadZinc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioSkip
ioSkip(handle, opts)
Apply a skipping operation to an input I/O handle. The following options are available (in order of processing):
- bom: skip byte order mark
- bytes: number of bytes to skip (must be binary input stream)
- chars: number of chars to skip (must be text input stream)
- lines: number of lines to skip
Skipping a BOM will automatically set the appropiate charset. If no BOM is detected, then this call is safely ignored by pushing those bytes back into the input stream. The following byte order marks are supported:
- UTF-16 Big Endian: 0xFE_FF
- UTF-16 Little Endian: 0xFF_FE
- UTF-8: 0xEF_BB_BF
Examples:
// skip leading 4 lines in a CSV file
ioSkip(`io/foo.csv`, {lines:4}).ioReadCsv
// skip byte order mark
ioSkip(`io/foo.csv`, {bom}).ioReadCsvmeta
| admin | ✓ |
| def | func:ioSkip |
| is | func |
| lib | lib:io |
| name | ioSkip |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioStreamCsv
ioStreamCsv(handle, opts: null)
Read a stream of dicts from a comma separated value file. This function uses the same options and semantics as ioReadCsv() except it streams the rows as dicts instead of reading to an in-memory grid. See Streams.
meta
| admin | ✓ |
| def | func:ioStreamCsv |
| is | func |
| lib | lib:io |
| name | ioStreamCsv |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioStreamLines
ioStreamLines(handle)
Read a stream of lines. Lines are processed according to InStream.eachLine. See Streams.
meta
| admin | ✓ |
| def | func:ioStreamLines |
| is | func |
| lib | lib:io |
| name | ioStreamLines |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioToBase64
ioToBase64(handle, opts: null)
Encode an I/O handle into a base64 string. The default behavior is to encode using RFC 2045 (see Buf.toBase64). Use the {uri} option to encode a URI-safe URI via RFC 4648 (see Buf.toBase64Uri). Also see ioFromBase64().
Example:
// encode string to base64
ioToBase64("myusername:mysecret")
// encode string to base64 without padding using URI safe chars
ioToBase64("myusername:mysecret", {uri})meta
| admin | ✓ |
| def | func:ioToBase64 |
| is | func |
| lib | lib:io |
| name | ioToBase64 |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioToHex
ioToHex(handle)
Encode an I/O handle into hexidecimal string.
meta
| admin | ✓ |
| def | func:ioToHex |
| is | func |
| lib | lib:io |
| name | ioToHex |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteCsv
ioWriteCsv(val, handle, opts: null)
Write a grid to a CSV (comma separated values) file.
CSV format is implemented as specified by RFC 4180:
- rows are delimited by a newline
- cells are separated by
delimiterchar - cells containing the delimiter,
"double quote, or newline are quoted; quotes are escaped as""
The following options are supported:
- delimiter: separator char as string, default is ","
- newline: newline string, default is "\n" (use "\r\n" for CRLF)
- noHeader: Set this option to prevent the column names from being written as a header row.
- stripUnits: write all numbers without a unit
Also ioReadCsv(), ioEachCsv(), and CSV.
meta
| admin | ✓ |
| def | func:ioWriteCsv |
| is | func |
| lib | lib:io |
| name | ioWriteCsv |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteExcel
ioWriteExcel(val, handle)
Write an Excel XLS file, where val may be:
- Grid - writted a a single worksheet
- Grid[] - each grid is exported as a separate worksheet
By default each worksheet is named "Sheet1", "Sheet2", etc. Use a title tag in Grid.meta to give the worksheets a specific name.
Example:
readAll(site).ioWriteExcel(`io/sites.xls`)meta
| admin | ✓ |
| def | func:ioWriteExcel |
| is | func |
| lib | lib:io |
| name | ioWriteExcel |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteHtml
ioWriteHtml(val, handle, opts: {})
Write an Axon data structure to HTML. The val must be an Axon type that can be converted to a Grid.
meta
| admin | ✓ |
| def | func:ioWriteHtml |
| is | func |
| lib | lib:io |
| name | ioWriteHtml |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteJson
ioWriteJson(val, handle, opts: null)
Write an Axon data structure to JSON. By default, Haystack 4 (Hayson) encoding is used. The val may be:
- One of the SkySpark types that can be mapped to JSON. See Json for type mapping.
The following options are supported:
- noEscapeUnicode: do not escape characters over 0x7F
- v3: Encode JSON using Haystack 3 encoding
- v4: Explicitly encode with Haystack 4 encoding (default)
meta
| admin | ✓ |
| def | func:ioWriteJson |
| is | func |
| lib | lib:io |
| name | ioWriteJson |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteJsonLd
ioWriteJsonLd(val, handle)
Write an Axon data structure to RDF JSON-LD format. The val must be an Axon type that can be converted to a Grid.
meta
| admin | ✓ |
| def | func:ioWriteJsonLd |
| is | func |
| lib | lib:io |
| name | ioWriteJsonLd |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteLines
ioWriteLines(lines, handle)
Write a list of string lines separated with "\n" character.
meta
| admin | ✓ |
| def | func:ioWriteLines |
| is | func |
| lib | lib:io |
| name | ioWriteLines |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWritePdf
ioWritePdf(val, handle, opts: {})
Render data to a PDF file. The grid meta "view" tag determines the visualization:
table: render grid as table (default)chart: render grid as chartfandoc: render string as fandoctext: render as plaintext
Options:
pageSize: determines the PDF page size
Examples:
// render as chart with default page size
read(power).hisRead(yesterday).ioWritePdf(`io/portrait.pdf`)
// render as chart with landscape page size of 11" x 8.5"
read(power).hisRead(yesterday).ioWritePdf(`io/landscape.pdf`, {pageSize:"11in,8.5in"})
// render table as single auto-fit page
readAll(site).ioWritePdf(`io/sites.pdf`, {pageSize:"auto"})Note: this feature is available in SkySpark only
meta
| admin | ✓ |
| def | func:ioWritePdf |
| is | func |
| lib | lib:io |
| name | ioWritePdf |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteStr
ioWriteStr(str, handle)
Write a string to an I/O handle.
meta
| admin | ✓ |
| def | func:ioWriteStr |
| is | func |
| lib | lib:io |
| name | ioWriteStr |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteSvg
ioWriteSvg(val, handle, opts: {})
Render data to an SVG file. Pass size option to specify the SVG viewBox, width, and height attribtues (defaults to "1000,800"). The visualization is determined by the grid meta "view" tag - see ioWritePdf() for specifics.
Examples:
read(power).hisRead(yesterday).ioWriteSvg(`io/example.svg`)
read(power).hisRead(yesterday).ioWriteSvg(`io/example.svg`, {size:"600,400"})Note: this feature is available in SkySpark only
meta
| admin | ✓ |
| def | func:ioWriteSvg |
| is | func |
| lib | lib:io |
| name | ioWriteSvg |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteTrio
ioWriteTrio(val, handle, opts: null)
Write dicts to a Trio file. The val may be can be any format accepted by toRecList().
Following options are supported
- noSort: marker to prevent tags from being sorted by name
meta
| admin | ✓ |
| def | func:ioWriteTrio |
| is | func |
| lib | lib:io |
| name | ioWriteTrio |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteTurtle
ioWriteTurtle(val, handle)
Write an Axon data structure to RDF Turtle format. The val must be an Axon type that can be converted to a Grid.
meta
| admin | ✓ |
| def | func:ioWriteTurtle |
| is | func |
| lib | lib:io |
| name | ioWriteTurtle |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteXeto
ioWriteXeto(val, handle, opts: null)
Write value to a Xeto text format file. See LibNamespace.writeData for details and options.
meta
| admin | ✓ |
| def | func:ioWriteXeto |
| is | func |
| lib | lib:io |
| name | ioWriteXeto |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteXml
ioWriteXml(val, handle)
Write a grid to an XML file.
meta
| admin | ✓ |
| def | func:ioWriteXml |
| is | func |
| lib | lib:io |
| name | ioWriteXml |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioWriteZinc
ioWriteZinc(val, handle)
Write a Grid to the Zinc format.
meta
| admin | ✓ |
| def | func:ioWriteZinc |
| is | func |
| lib | lib:io |
| name | ioWriteZinc |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioZipDir
ioZipDir(handle)
Read a zip file's entry listing, return a grid with cols:
path: path of entry inside zip as Urisize: size of file in bytes or nullmod: modified timestamp or null if unknown
The handle must reference a zip file in the file system. Use ioZipEntry() to perform a read operation on one of the entries in the zip file.
Example:
ioZipDir(`io/batch.zip`)meta
| admin | ✓ |
| def | func:ioZipDir |
| is | func |
| lib | lib:io |
| name | ioZipDir |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |
def
func:ioZipEntry
ioZipEntry(handle, path)
Return a I/O handle which may be used to read from a zip entry within a zip file. The handle parameter must be an I/O handle which references a zip file in the file system. The path parameter must be a Uri which identifies the path of the entry within the zip file. See ioZipDir() to read the listing of paths within a zip.
Example:
// read CSV file from within a zip
ioZipEntry(`io/batch.zip`, `/zone-temp.csv`).ioReadCsvmeta
| admin | ✓ |
| def | func:ioZipEntry |
| is | func |
| lib | lib:io |
| name | ioZipEntry |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| func | Axon function |