Auto Save option as textfile at regular intervals

One of Ignition Server 7.2.1 is connected with ABB 800 XA system. Now I want to store data in text file format (.txt) from ignition. I would like to know whether Ignition have this option?

         We have seen this kind of options in Charts eg: Save in the format of text file (.txt) or Excel or etc. But I require in text file (.txt) format with Auto save option (interval). The data should be stored in one text file automatically from Ignition. Here I can give you what my requirement is;
  1.  A Folder  with name ‘ignition' should be created in D:\  drive .
    
  2.  The Text file should be in  ‘D:\ignition’ folder and the path should not be changed  at any time.
    
  3.  The format and position of parameter recordings should not be changed. (i.e., the text file format)

This can be done easily in scripting. In fact, I do something similar where I store all of my queries and other events into a log file, and then zip it at regular intervals.

I have no idea what your data looks like (does it come in one line at a time? A big blob? Does it need to be parsed?), but here is a quick hack that you can connect to a button press event to see how to write to a file.

I defined some data in a list, created a calendar object so I can get some basic time stamp info, and then I iterate through the list, creating a line in the file for each element in the list. The ‘1’ in the “F.FileWriter(filename,1)” indicates “Append Mode” if you want to just keep writing to the same file. Change it to ‘0’ to create a new file each time (wouldn’t make much sense in this example though).

Again, this is just a quick hack, but it should point you in the right direction if you want to give scripting a shot:

text=['Line 1','Line 2','Line 3']

import java.io as F
from java.util import Calendar
c=Calendar.getInstance()
tMs=c.getTimeInMillis()
adir = "C:\\IgnitionTextFiles\\"

filename = adir+"Test_File_%d_%d.txt"%(c.get(Calendar.YEAR),c.get(Calendar.DAY_OF_YEAR))

for t in text:
	line ='This is %s at %d'%(t,tMs)+'\n'
	fstream = F.FileWriter(filename,1)	
	out = F.BufferedWriter(fstream)
	out.write(line)
	out.close()

Thanks for your help.

I have seen one more coding in Ignition help. But i was unable to see the updated value in this. Can any one just help me to loop the data (ie) { data = rs[0][0]+","+rs[0][1] }

[color=#FF0040]rs = system.db.runQuery(“SELECT date_format(t_stamp, ‘%m/%d/%Y %r’), stackemission FROM pollution where day(t_stamp) = day(now())”)

data = rs[0][0]+","+rs[0][1]

pollcontrol = “karm”+","+“SARCLAB”+","+“1”+","+data+’\n’

system.file.writeFile(“D:\stack_pollution.txt”, pollcontrol, 1)[/color]

Do you mean that you want data = rs[0][0]+","+rs[0][1] +","+rs[0][2]+… ?

If so, you can do something like this:rs = system.db.runQuery("SELECT date_format(t_stamp, '%m/%d/%Y %r'), stackemission FROM pollution where day(t_stamp) = day(now())") data = "" #loop through each item in the first row of the resultset for item in rs[0]: if data == "": #if this is the first, no comma data = item else: #add a comma and the next item data = data+","+item print data