> ## Documentation Index
> Fetch the complete documentation index at: https://www.integrate.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ETL: Google Sheet에서 데이터 검색

> Integrate.io ETL의 REST API 컴포넌트를 사용해 Google Sheets에서 시트 ID와 셀 범위를 지정하고 batchGet 엔드포인트를 통해 데이터를 읽어 들이는 방법과 인증 설정 방법을 자세히 설명합니다. 처음 사용하시는 분들도 이해하기 쉽게 작성했습니다.

이 가이드에서는 Xplenty의 Rest API 컴포넌트를 통해 Google Sheet에서 데이터를 읽는 방법에 대해 설명합니다.

**Rest API** 컴포넌트 **설정**

## **인증(Authentication) 설정**

미리 연결 화면에서 만든 Google Sheet 인증을 선택합니다.

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-1.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=59f5e52e3ac9d82ff785a624b34ee88d" alt="restapi-part02-ko image 1" width="1200" height="557" data-path="images/korean-knowledge-base/restapi-part02-ko/image-1.webp" />
</Frame>

## **URL 지정 방법**

**URL:**`[https://sheets.googleapis.com/v4/spreadsheets/](https://sheets.googleapis.com/v4/spreadsheets/)시트_ID/values:batchGet?ranges=셀_범위&majorDimension=ROWS`

*

**시트\_ID:**

Google Sheet URL에서 시트 ID 가져오기

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-2.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=4abd5ca42209add10bf38a067d32680c" alt="restapi-part02-ko image 2" width="1200" height="807" data-path="images/korean-knowledge-base/restapi-part02-ko/image-2.webp" />
</Frame>

*

**셀\_범위**
예) A1:G1000 (A열의 1행부터 G열의 1000행까지)

## **Response 설정**

JSONPath Expression에 `$..values[*]`를 입력

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-3.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=d44370f04fb369ade312f52d0c92db97" alt="restapi-part02-ko image 3" width="1200" height="557" data-path="images/korean-knowledge-base/restapi-part02-ko/image-3.webp" />
</Frame>

## **필드 선택**

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-4.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=311ec3ba9fa12875e20d24e274965a20" alt="restapi-part02-ko image 4" width="1200" height="790" data-path="images/korean-knowledge-base/restapi-part02-ko/image-4.webp" />
</Frame>

**획득한 JSON 플랫화**

## **변환 1 : BAG 형에서 Tuple 형으로 변환**

Select 컴포넌트에서 BagToTuple함수를 사용하여 Tuple 형식으로 변환

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-5.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=2f5c7464cdc12d492462f145461fb51f" alt="restapi-part02-ko image 5" width="1200" height="731" data-path="images/korean-knowledge-base/restapi-part02-ko/image-5.webp" />
</Frame>

## **변환 2:배열 번호를 지정해, 각 열을 각각 취득한다**

각각의 열을 배열 번호(\$0)를 지정해 취득함과 함과 동시에, Chararray 함수로 문자열형으로 변환한다

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-6.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=b949689bb6470522de6c5da0dbe4c040" alt="restapi-part02-ko image 6" width="1200" height="731" data-path="images/korean-knowledge-base/restapi-part02-ko/image-6.webp" />
</Frame>

## **헤더 행을 필터로 제외**

1행이 헤더일 경우, 필터로 제외한다 (Rest API측의 셀의 범위 지정으로 헤더행을 제외하는 방법도 있다.)
예) id열에 「Id」라고 하는 문자가 포함 없는 데이터만 추출

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-7.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=a3965611f11a0f19f97086c8ea9ae240" alt="restapi-part02-ko image 7" width="1200" height="761" data-path="images/korean-knowledge-base/restapi-part02-ko/image-7.webp" />
</Frame>

저장 대상의 **컴포넌트를 설정하고 작업을 실행하고 확인**

마지막으로 데이터베이스, DWH, 스토리지 등에 저장하면 완료됩니다.

## **패키지 전체도**

예) Snowflake가 저장 대상인 경우 다음과 같은 흐름이 됩니다.

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-8.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=425f727c63a74e7510777c9067cb2b81" alt="restapi-part02-ko image 8" width="1200" height="801" data-path="images/korean-knowledge-base/restapi-part02-ko/image-8.webp" />
</Frame>

## **데이터가 올바르게 반영되었는지 확인**

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-9.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=9d83a48b2b5f838f64c0faa92af135cd" alt="restapi-part02-ko image 9" width="1200" height="266" data-path="images/korean-knowledge-base/restapi-part02-ko/image-9.webp" />
</Frame>

**Google Sheet에 쓰기도 가능**

Xplenty에서는 Select 컴포넌트에 Curl 요청을 작성하여 Google Sheet에 쓰기도 가능합니다.

<Frame>
  <img src="https://mintcdn.com/integrateio/iVRIdUvvN5zDvCJc/images/korean-knowledge-base/restapi-part02-ko/image-10.webp?fit=max&auto=format&n=iVRIdUvvN5zDvCJc&q=85&s=ec6e68d5b2e62de35f32ac243a7e717e" alt="restapi-part02-ko image 10" width="1200" height="849" data-path="images/korean-knowledge-base/restapi-part02-ko/image-10.webp" />
</Frame>

**쓰기 리퀘스트의 예**
`CCurl(CONCAT('&lt;[https://sheets.googleapis.com/v4/spreadsheets/](https://sheets.googleapis.com/v4/spreadsheets/)>', '$spreadsheetId', '/values:batchUpdate'),'POST','&#123;"Accept":"application/json"&#125;',CONCAT('&#123;"valueInputOption":"RAW","data":[&#123;"range":"','$range','","majorDimension": "ROWS","values": [', BagToString(data, ','), ',]&#125;]&#125;'), '$connection_id')`

**위 요청에서 사용하는 변수 정보**

*

`$spreadsheetId`: GoogleSheet ID 지정

*

`$connection_id`: Xplenty의 연결 ID 지정 (연결 화면에서 확인할 수 있습니다)
예 : GOOGLESHEETS\_CONNECTION\_9215

*

`$range`: 시트 이름과 셀 범위 지정
예: campaign!A1:N100000
