Insert CSV in Zoho Sheet
Table of Contents
Description
The zoho.sheet.insertCSV task is used to insert comma-separated values (CSV) into the specified worksheet of Zoho Sheet file. This task is based on the Zoho Sheet API - Append rows with CSV data.
- On average, it takes about a minute to index a file/folder after it is created or updated. This indexing time can increase if the queue size increases. You will not get the expected result if you execute zoho.sheet.insertCSV task before the Zoho Sheet file (into which you need to insert values) is indexed.
- This task/method will insert the CSV only on the specified row and column in the parameters i.e ., the inserted data will not be appended after the last utilized row of the worksheet.
Syntax
<response> = zoho.sheet.insertCSV(<resource_id>, <worksheet_name>, <csv_data>, <row>, <column>, <connection>);
Params | Data type | Description |
<response> | KEY-VALUE | The status of the executed task. |
<resource_id> | TEXT | The ID of the Zoho Sheet file into which the CSV data needs to be inserted. Note: The resource_id can be obtained from the URL of the Zoho sheet file. The URL is in the following format: https://sheet.zoho.com/sheet/open/<resource_id>/sheets/<worksheet_name> |
<worksheet_name> | TEXT | The name of the worksheet into which the CSV data needs to be inserted. |
<csv_data> | TEXT / FILE | The comma separated values that need to be inserted. |
<row> | NUMBER | The row index number of the cell into which the first value of the CSV data needs to be inserted. The remaining values are inserted into the consecutive cells of the same row. |
<column> | NUMBER | The column index number of the cell into which the first value of the CSV data needs to be inserted. Note: The column_index needs to be supplied with the number equivalent of the column index (in letters). The index number starts with 1. For example, the index number of the column - A is 1 and the index number of the column - AA is 27. |
<connection> | TEXT | The link name of the connection. Note:
|
URL format: https://sheet.zoho.com/sheet/open/<resource_id>/sheets/<worksheet_name>
/ranges/<cell_range>
Example 1: Insert CSV data into a single row of Zoho Sheet file
The following script inserts CSV data into the specified row of the worksheet - Sheet1 with the resource ID - eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41:
response = zoho.sheet.insertCSV("eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41","Sheet1","Ben,ben@zylker.com,Trade Show,350,High", 1, 1, "Sheet_connection");
where:
response
"eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41"
"Sheet1"
"Ben,ben@zylker.com,Trade Show,350,High"
1
1
"Sheet_connection"
Example 2: Insert CSV data into multiple rows of Zoho Sheet file
The following script inserts the specified CSV data into the worksheet - Sheet1 with the resource ID - eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41:
response = zoho.sheet.insertCSV("eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41","Sheet1","Advertisement,200,High\nTrade Show,100,High", 1, 1, "Sheet_connection");
where:
"Advertisement,200,High\nTrade Show,100,High"
Example 3: Insert CSV data into Zoho Sheet at the specified cell reference
The following script inserts the CSV data - "Advertisement,200,High" into the specified worksheet. The first value - Advertisement is inserted into the cell - C8 of the worksheet - Sheet1 with the resource ID - eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41. The remaining values are inserted into the consecutive cells of the same row (index number: 8).
response = zoho.sheet.insertCSV("eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41","Sheet1","Advertisement,200,High", 8, 3, "Sheet_connection");
where:
8
3
Example 4: Fetch a CSV file from cloud storage and insert the values into the specified Zoho sheet
The following script inserts the CSV data fetched from cloud storage using the invokeUrl task into the worksheet - Sheet2 with the resource ID - eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41:
csv_data=invokeUrl [ url: "http://insight.dev.schoolwires.com/HelpAssets/C2Assets/C2Files/C2ImportCalEventSample.csv" type: GET ]; response = zoho.sheet.insertCSV("eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41","Sheet2",csv_data, 1, 1, "Sheet_connection");
where:
csv_data
Response Format
Success Response
The success response will be returned in the following format:
{}
"method": "worksheet.csvdata.set",
"status": "success"
Failure Response
The failure response for invalid resource ID will be returned in the following format:
{
"error_message": "The workbook does not exists",
"error_code": 2862
}The failure response for incorrect or non-existent worksheet name will be returned in the following format:
{
"error_message": "The sheet does not exists",
"method": "worksheet.csvdata.set",
"error_code": 2863,
"status": "failure"
}