# Script to write to .txt file

**URL:** <https://forum.universal-robots.com/t/script-to-write-to-txt-file/30290>\
**Category:** URScript\
**Created:** [September 5, 2023, 2:26pm UTC](https://forum.universal-robots.com/t/script-to-write-to-txt-file/30290 "2023-09-05T14:26:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![g.mat](https://avatars.discourse-cdn.com/v4/letter/g/ea5d25/32.png) [@g.mat](https://forum.universal-robots.com/u/g.mat)\
**Post date:** [September 5, 2023, 2:26pm UTC](https://forum.universal-robots.com/t/script-to-write-to-txt-file/30290/1 "2023-09-05T14:26:28Z")

</div>

Hi,

Is it possible to write to an existing .txt or .csv file on the robot in order to create a log of sorts?

My idea is to record variable and time data for troubleshooting purposes. Things like:

- Program Start Time
- “Var\_1” = xxx
- “Var\_2” = xxx
- “Operation X completed”
- Program end Time

I’ve seen the use of txtmsg() in other posts, but would like to avoid saving to log\_history.txt if possible since it’s my understanding that it can be overwritten if file size exceeds a certain threshold. I would also like to avoid using a xmlrpc daemon as I don’t currently have hardware available or permissions to connect a PC.

---

<div class="post-metadata">

**Author:** ![hbrown](https://avatars.discourse-cdn.com/v4/letter/h/b9e5f3/32.png) [@hbrown](https://forum.universal-robots.com/u/hbrown)\
**Post date:** [September 11, 2023, 12:49pm UTC](https://forum.universal-robots.com/t/script-to-write-to-txt-file/30290/2 "2023-09-11T12:49:45Z")

</div>

Hello,

I have used this nifty program template from Robotiq to export variables to a PC in CSV format.

[https://dof.robotiq.com/discussion/724/data-logging-from-a-ur-program-to-an-external-pc](https://dof.robotiq.com/discussion/724/data-logging-from-a-ur-program-to-an-external-pc)

Hope it helps,
