T()

Read(2772) Label: file extension,

Description:

Read in content of a file according to file extension and return result as a table sequence.

Syntax:

T(fn:A,Fi,…;s)

Note:

The function read in content of file fn according to the file extension and returns result as a table sequence. The supported file types are txt/csv/xls/xlsx/btx/ctx.

 

When parameter A is present, write it to fn. The method is to first clean up the content of fn and then write data in.

Parameter:

fn

A data file

A

A record sequence/cursor; can be absent

Fi

A column header in the data file, which can be represented by #1,#2,… (column 1, column 2, …); can be absent

s

A separator that can be absent if the data file is of text format; it is the sheet name, which should not exceed 31 characters and contain special characters []:/\?*, if the file is of format of xls or xlsx

Option:

@b

Won’t read in the column headers; will read in them by default

@c

Read in the file content as a cursor

Return value:

A table sequence

Example:

 

A

 

1

D:\City.txt

 

2

=T(A1)

Read all content of City.txt:

3

=T(A1,CityName)

Read in CityName column of City.txt:

4

=T(A1,#2,#3)

Read in column 2 and column 3 of City.txt:

5

=T("D:/emp.xls";"emp2018")

Read in content of sheet named emp2018 from emp.xls:

6

=T("D:/users.txt";",")

Read in content of comma-separated users.txt. Below is the file’s content:

The table sequence returned:

7

=T("D:/user-a.txt":A6)

Delete all content from user-a.txt and write A6’s data in it:

8

D:\node.txt

node.txt doesn’t have headers. Its content is as follows:

9

=T(A8)

Read in content of node.txt and make the first row as headers:

10

=T@b(A8)

Use @b function to assume that there aren’t headers in the file:

11

=T@c(A8)

Use @c opton to read in the file content as a cursor