# Saving to the Same CSV file

**URL:** <https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087>\
**Category:** General Discussion\
**Created:** [October 28, 2020, 11:10am UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087 "2020-10-28T11:10:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 11:10am UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/1 "2020-10-28T11:10:16Z")

</div>

I am positive it is my lack of expertise that prevents me from knowing this, but how do I save a report file to the **same** CSV file instead of making a new one each time. I have over a hundred CSV files when all I need is to save the new data to the existing one and repeat.  
This is in the Report / Schedule actions.  
Thank you for any assistance.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 28, 2020, 12:36pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/2 "2020-10-28T12:36:26Z")

</div>

Could use the runScript scheduled action and do something like

```
myFile = "C:\\MyFolderPath\\TestCSV.csv"
system.file.writeFile(myFile,reportBytes,1)

```

The 1 on the end specifies Append.

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 1:22pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/3 "2020-10-28T13:22:30Z")

</div>

I will give it a try.  
Thank you.

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 1:36pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/4 "2020-10-28T13:36:45Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/2/02fe0dcd3efe41c93e80daa9d1a3f965727ef6d3.png)  
MMaynard,  
I hope the screen shot appears.  
With these changes, Ignition wont save anything now.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 28, 2020, 1:39pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/5 "2020-10-28T13:39:43Z")

</div>

You put a 10 instead of 1 for the boolean “append” parameter.

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 28, 2020, 1:41pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/6 "2020-10-28T13:41:10Z")

</div>

@MMaynard gave you a python script but you’re in an expression editor. I’m not sure if what you’re trying to do is possible without custom scripting? Maybe a report expert could shed some light @KathyApplebaum

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 28, 2020, 1:43pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/7 "2020-10-28T13:43:59Z")

</div>

What was your original FileName settings for Save File before adding the python script?

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 1:44pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/8 "2020-10-28T13:44:32Z")

</div>

{Report.Name}

- " "
- dateFormat(now(), “M-d-yy hha”)

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 1:45pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/9 "2020-10-28T13:45:24Z")

</div>

1 {Report.Name}  
2 + " "  
3 + dateFormat(now(), “M-d-yy hha”)  
4

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 28, 2020, 1:48pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/10 "2020-10-28T13:48:18Z")

</div>

try this:

```auto
{Report.Name}

```

What’s happening is whenever the file is saved your specifying a new name with the date stuff.  
Remove the date stuff and your file will overwrite every time.

You can manually execute the schedule by clicking the arrows:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/f/9f687f6bf93f20832ee6921c2f3543bbc4fa2edf.png)

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 1:51pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/11 "2020-10-28T13:51:15Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/0/900dce48fc969553331379872c5c3fc0a25ce185.png)  
With the current script, I get a new file every scheduled save.  
I dont want to overwrite the data, I want to add to a single file.

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [October 28, 2020, 1:53pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/12 "2020-10-28T13:53:27Z")

</div>

Oh I see. ~~I’m not sure if this is possible without a runScript() call to a custom script.~~  
Change your Action to a Run Script and use @MMaynard code.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 28, 2020, 1:55pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/13 "2020-10-28T13:55:15Z")

</div>

Dont use a save file action, use a run script action with the code I gave you and a non changing file name.

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 2:25pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/14 "2020-10-28T14:25:09Z")

</div>

Where am I going wrong?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b64ffb44304c6e70edcf31abb570972750fa3d64.png)

---

<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:** [October 28, 2020, 3:01pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/15 "2020-10-28T15:01:56Z")

</div>

You aren’t indented as python expects, and you aren’t doubling your backslashes.

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 3:09pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/16 "2020-10-28T15:09:26Z")

</div>

Hourly\_DT\_Query = “C:\Path\ToFolder\HourlyDTQuery.csv”  
system.file.write(Hourly\_DT\_Query,reportBytes,1)

This is my last iteration and it still doesnt work

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 3:09pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/17 "2020-10-28T15:09:54Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/0/c09ca076ea35d2823349fb7cda75adf5111498e4.png)

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [October 28, 2020, 3:11pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/18 "2020-10-28T15:11:31Z")

</div>

Only one \ after Path, double it

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 3:17pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/19 "2020-10-28T15:17:41Z")

</div>

```
Hourly_DT_Query = "C:\\Path\\ToFolder\\HourlyDTQuery.csv"
system.file.write(Hourly_DT_Query,reportBytes,1)

```

Still no luck

---

<div class="post-metadata">

**Author:** ![jim.borener](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jim.borener](https://forum.inductiveautomation.com/u/jim.borener)\
**Post date:** [October 28, 2020, 3:18pm UTC](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087/20 "2020-10-28T15:18:46Z")

</div>

My file name is Hourly DT Query

[Next page](https://forum.inductiveautomation.com/t/saving-to-the-same-csv-file/40087.md?page=2)
