Choose where you’d like to start

Insert CSV in Zoho Sheet

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.

Note:
  • 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>);
where:
ParamsData typeDescription

<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>
/ranges/<cell_range>

<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:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory in order for new integration tasks (created after the deadline specified in the post) to work as expected. Existing integration tasks will continue to work with or without the connections parameter until you manually delete the authtoken from accounts.
  • Scopes required for this task as mentioned in API docs - ZohoSheet.dataAPI.UPDATE, ZohoSheet.dataAPI.READ.
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections
Note: The resource_id and worksheet_name parameters can be obtained from the URL of the Zoho Sheet file.

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
The KEY-VALUE response returned by Zoho Sheet.
"eev4nXXXXXXXXXXXXXXXXXXXXXXXXXXXcff41"
The TEXT that represents the ID of the Zoho Sheet file.
"Sheet1"
The TEXT that represents the name of the worksheet into which the CSV data needs to be inserted.
"Ben,ben@zylker.com,Trade Show,350,High"
The TEXT that represents the CSV data.
1
The NUMBER that represents the row index number of the cell from which the CSV data needs to be inserted.
1
The NUMBER that represents the column index number of the cell from which the CSV data needs to be inserted.
"Sheet_connection"
The TEXT that represents the link name of the Zoho 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"
The TEXT that represents the CSV data that needs to be inserted.
Note: The \n represents a new row. In other words, the comma-separated values following the \n will be inserted into the next row.

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
The NUMBER that represents the row index number of the cell from which the CSV data needs to be inserted.
3
The NUMBER that represents the column index number of the cell from which the CSV data needs to be inserted.

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
The FILE that holds the comma-separated values fetched from the specified URL using the invokeUrl deluge task.
Note: The CSV data is fetched from the cloud using the invoke URL task. To learn more about the invokeUrl task, click here.

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"
      }

Related Links

Get Started Now

Execute