Skip to main content

File Utility Methods

FILEUTILITY contains methods which are helpful for parsing data from file formats like CSV and JSON. These methods return the parsed data in JSON format which is suitable to be used with controls on the UI builder.

FILEPARSER

FILEUTILITY.FILEPARSER method can be used to parse files of multiple different formats and get output into JSON format. This method returns a Promise. The accepted file formats include csv , xml and json.

Parameters
ParameterAcceptsPossible values
urlStringany valid url for csv, json or xml file
Usage
FILEUTILITY.FILEPARSER(url);
Example
await FILEUTILITY.FILEPARSER("https://dronamobilepublic.s3.amazonaws.com/DRONA5_Team19020/content/app/images/UiFhDLxjT5.csv");

PARSEXLSX

FILEUTILITY.PARSEXLSX method can be used to parse excel sheets and get output into JSON format. This method returns a Promise. The accepted file format is xlsx. The second parameter sheetNumber is optional. If your excel file has multiple sheets, you can specify the sheet number which you want to parse. By default the utility will parse the first sheet.

Usage
FILEUTILITY.PARSEXLSX(url,sheetNumber);
Parameters
ParameterAcceptsPossible values
urlStringany valid url for xlsx file
sheetNumber (Optional)Numberany numerical value
Example
await FILEUTILITY.PARSEXLSX('https://dronamobilepublic.s3.amazonaws.com/DRONA5_Team19020/content/app/images/WKEa5OPsEw.xlsx');

DOWNLOADFILEAS

FILEUTILITY.DOWNLOADFILEAS method can be used to download json data into different file formats. The supported file formats are json, csv and xml.

Usage
FILEUTILITY.DOWNLOADFILEAS(data,format);
Parameters
ParameterAcceptsPossible values
dataJson arrayarray of json objects
formatString'json','csv','xml'
Example
FILEUTILITY.DOWNLOADFILEAS(data,'csv');