Reading a text file and creating tags

Hey All,
I am trying to read a text file and create tags for each output that is written on the text file. The problem I am having now is, I am just able to grab the entire file. I want to grab specific out values ( string or int) and convert that to a tag. Also want to have it in a loop that way it kinda reads updated data continuously. Please Help!

I created a button and this is my script so far:

path = system.file.openFile(’.txt’)
if path != None:
contents = system.file.readFileAsString(path)
system.tag.writeToTag(“WriteTags/write”, contents) event.source.parent.getComponent(“Text Area”).text = contents

Hello,

I am attempting to do the same process you are going for here. Did you make any headway on grabbing specific contents from the text file?

Welcome!

You want to read each line and split it if it has a CSV separator

Here is an example

if os.listdir(filepath):
				
				with open(os.path.join(filepath,file_xtn),'r'):
				
					first_line_ignore = file.readline()
					#print len(file)
					for line in file.readlines():
						data = line.split(";")
						yearX = line.find(year) 
						(month_str,day_str
						,) = map(lambda x,y:line[yearX+x:yearX+y],((-3,-1,),(-6,4,),))
						datetimef = '{0}-{1}-{2} {3}'.format(year,month_str,day_str,data[1])
						date_str = datetimef[:10]
						system.db.runSFPrepUpdate("INSERT INTO rapid_raw_rest (date_time, batch, colour, profile_code, length, rapid) VALUES (?, ?, ?, ?, ?, ?)", [datetimef, data[2], data[3], data[4], data[5], rapid], ["Xeon"])

Think the formatting skewed slightly on copy paste to forum, it should be 1 tab indent per section after a colon

Hi temes,

Is that split concept working with code?

Log files.