DataFile Component
Properties
columnNames Retrieve the column names of the currently loaded Source file. For CSV files, this will return a List of entries in the first row. For JSON files, this will return a List of keys in the JSON object.
Data type: array |
||
Designer Writable | false | |
Code Writeable | false | |
Code Readable | true |
let variable = datafileName.columnNames |
columns Retrieve a List of columns of the currently loaded Source file.
Data type: array |
||
Designer Writable | false | |
Code Writeable | false | |
Code Readable | true |
let variable = datafileName.columns |
defaultScope Specifies the default scope for files accessed using the File component. The App scope should work for most apps. Legacy mode can be used for apps that predate the newer constraints in Android on app file access.
Data type: string |
||
Designer Writable | true |
<datafile name="datafileName" defaultScope="App"> |
Code Writeable | false | |
Code Readable | false |
rows Retrieve a List of rows of the currently loaded Source file.
Data type: array |
||
Designer Writable | false | |
Code Writeable | false | |
Code Readable | true |
let variable = datafileName.rows |
sourceFile Sets the source file to parse data from, and then parses the file asynchronously. The results are stored in the Columns, Rows and ColumnNames properties. The expected formatting of the file is either the CSV or JSON format.
Data type: string |
||
Designer Writable | true |
<datafile name="datafileName" sourceFile="Test sourceFile"> |
Code Writeable | false | |
Code Readable | false |
class The styling class of the the component
Data type: string |
||
Designer Writable | true |
<datafile name="datafileName" class="Test class"> |
Code Writeable | false | |
Code Readable | false |
id The styling id of the the component
Data type: string |
||
Designer Writable | true |
<datafile name="datafileName" id="Test id"> |
Code Writeable | false | |
Code Readable | false |
name The name of the component that will be used to refer to it in code.
Data type: string |
||
Designer Writable | true |
<datafile name="datafileName" name="testComponent"> |
Code Writeable | false | |
Code Readable | false |
Methods
Method name | Description | Parameters | ||
---|---|---|---|---|
readFile |
Indicates source file to load data from. The expected format of the contents of the file are either CSV or JSON. Prefix the fileName with / to read from a specific file on the SD card (for example, /myFile.txt will read the file /sdcard/myFile.txt). To read assets packaged with an application (also works for the Companion) start the fileName with // (two slashes). If a fileName does not start with a slash, it will be read from the application's private storage (for packaged apps) and from /sdcard/AppInventor/data for the Companion. datafileName.readFile(fileName) datafileName.readFile("Test fileName") |
|