A .export()

Read(386) Label: sequence, string,

Description:

Convert a sequence into a string.

Syntax:  

A.export(x:F,…;s)

Note:

The function separates each selected fields x of records in table sequence/record sequence/sequence A with the user-defined separator and returns the result as a string. The name of the resulting field in the string is F. If x isn’t specified, then export all fields. Return a one-field string without a field name if A is a simple sequence; use separator when A’s members are sequences. A serial byte value is stored as an integer.

 If parameters x:F are absent and if A is a sequence of record, then these records should be of same structure.

   The function returns JSON strings when records or members of A is record, sequence or table sequence; and returns a hexadecimal string when records or members of A are serial byte keys.

Parameters:  

A

A table sequence/record sequence/sequence to be exported.

x

Fields to be exported. If omitted, then export all fields of A.

F

Name of the resulting field in the string. If omitted, then use the original field name.

s

User-defined field separator. The default is tab.

Options:  

@t

The column names will be written to the string as the first record.

@c

Use comma as the separator when the parameter s is absent, but the user-defined separator s should take priority when there are both s and @c option.

@w

Use Windows-style \r\n line break; by default the line break is specified by the operating system.

@q

Enclose the exported text field values and headers with quotation marks

@o

Perfrom escaping according to the Excel rule, which treats two double quotation marks as one and does not escape the other characters Need to work with @q.

Return value:

String.

Example:

 

A

 

1

=demo.query("select EID,NAME from EMPLOYEE")

 

2

=A1.export()

Parameters x, F, and s are omitted.

3

=A1.export(;"|")

Specify the separator as "|".

4

=A1.export@t(EID:id,NAME:name;",")

Specify to-be-exported fields and the separator; make column names the first record and write it at the beginning of the exported string

5

[1,23,34,45]

 

A sequence

6

=A5.export()

 

7

=A1.export@c()

 With @c option, use default separator comma when parameter s is absent

8

=A1.export@w()

 

9

=["12\r34","aa\nbb"]

 

 

10

=A9.export()

 

11

=A9.export@q()

 With @q option, the exported content contains quotation marks

12

<xml><row><DEPTID>1</DEPTID><DEPTNAME>sale</DEPTNAME><FATHER>12</FATHER></row><row><DEPTID>10</DEPTID><DEPTNAME>create</DEPTNAME><FATHER>12</FATHER></row></xml>

 

13

=xml@s(A13)

Return a sequence of sequences

Expand members of the sequence as follows:

Then expand sub-members of the sequecne as follows:

14

=A14.export()

Return JSON strings

15

=file("D://t4.txt").import@coq()

16

=A15.export@coq()

With @o option, two double quotation marks are treated as one

Note:

Format of the string: Separate the records by space, and the fields by the user-defined separator. The default separator is tab.

Related functions:

f.import()

f.export()