# Export data into a Google Drive folder

**URL:** <https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [March 26, 2021, 8:57pm UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978 "2021-03-26T20:57:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DougSN](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DougSN](https://forum.inductiveautomation.com/u/DougSN)\
**Post date:** [March 26, 2021, 8:57pm UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/1 "2021-03-26T20:57:17Z")

</div>

Has anyone successfully written code to export data to a file on Google Drive through Ignition? I would want to have a gateway script that checks for the data, creates a dataset, and then puts it into a spreadsheet on Google Drive. CSV would also be acceptable. I know how to create the dataset, just no idea how to get it into a spreadsheet on Google Drive.

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [March 26, 2021, 9:12pm UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/2 "2021-03-26T21:12:09Z")

</div>

I’ve done this in the past by setting up [Google Drive Backup and Sync](https://support.google.com/drive/answer/2374987?hl=en) on the Ignition gateway. This allows you to save to the synced GDrive folder the same way you would save to any other location on your Gateway’s filesystem. (Take a look at the `system.file.saveFile()` and `system.file.writeFile()` functions, just keep in mind that these will need to run on your Gateway to have access to the synced GDrive folder)

To convert your dataset to a CSV you can use [`system.dataset.exportCSV()`](https://docs.inductiveautomation.com/display/DOC81/system.dataset.exportCSV).

Note: With the GDrive Backup & Sync, you will need to have a user that can be signed in at all times on the Gateway. Anyone with access to the Gateway will be able to access the contents of that synced GDrive folder. I created a stand alone Google user for this purpose.

---

<div class="post-metadata">

**Author:** ![DougSN](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@DougSN](https://forum.inductiveautomation.com/u/DougSN)\
**Post date:** [March 26, 2021, 9:29pm UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/3 "2021-03-26T21:29:51Z")

</div>

Hmm, good point. It would be cleaner to use scripting to send it directly to the Google Drive service/API, but your way is probably a lot easier to set up within the Ignition environment.

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [September 17, 2024, 1:13am UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/4 "2024-09-17T01:13:36Z")

</div>

I found some issue here:

1. google drive backup app is installed on the gateway machine, windows server OS.
2. the drive is mounted as G drive.
3. open the ignition designer, on the script console. I can save file to G drive.
4. program the script associated to a gateway tag, once the value is true, trigger the script to save file to G drive.
5. toggle this gateway tag, the scrip is executed, but the file was not saved to the G drive.

What's the difference between executing the same script from the script console and from the gateway directly?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 17, 2024, 2:15am UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/5 "2024-09-17T02:15:08Z")

</div>

Different user context. Background services' network mappings are independent of logged in desktop users.

This is one of the reasons you should not run the designer on the same system as the gateway--misleading commonality.

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [September 17, 2024, 2:25am UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/6 "2024-09-17T02:25:39Z")

</div>

thanks for the kind reply, as always.

I am still confused with the scope of usage of the script execution and user rights when the scripts runs.

Can you please advise what should I do to correct this issue?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 17, 2024, 3:19am UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/7 "2024-09-17T03:19:03Z")

</div>

The service needs to map the google drive. I don't know what is possible for service users and google drives.

(I don't take care of Windows systems. I'll deploy on client-provided Windows systems--I won't provide or maintain Windows itself, or any of its related tech. Others will have to answer--if there is an answer.)

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [September 17, 2024, 3:28am UTC](https://forum.inductiveautomation.com/t/export-data-into-a-google-drive-folder/44978/8 "2024-09-17T03:28:03Z")

</div>

> Blockquote  
> Note: With the GDrive Backup & Sync, you will need to have a user that can be signed in at all times on the Gateway. Anyone with access to the Gateway will be able to access the contents of that synced GDrive folder. I created a stand alone Google user for this purpose.

can you explain how you setup this standalone google user?  
I am having some issue saving to google drive, it might be related to this setup.
