Combine a "String" and a Tag Value in a file name

Hi All,
I have another “Newbie” question. I have searched previous topics with no success and I’m not even sure if what I’m trying to achieve is possible.
I am trying to combine a “string” with a tag value to create a file name when using ‘ExportCSV’.

I have created a tag called 'FileDate" = The current date in the format “yyyyMMdd”. I am trying to combine this tag with a string to create a new file name as the name of the saved file prompt when exporting to a csv.
In the script below, I would like the ‘FileName’ = Products_20180410
I appears that the “ExportCSV” requires a literal string as a file name. Is it possible to substitute a tag for the file name?

FileDate =, “yyyyMMdd”)

table = event.source.parent.getComponent(“Table”)
filePath = system.dataset.exportCSV(‘C:\SiteOverview\FileName’, 1,
if filePath != None:“file:///”+filePath.replace(’\’,’/’))

So you’re just trying to concatenate strings? In python you can use the + operator like this:

filePath = 'C:/My/Directory/' +'myTagPath').value

But I guess you don’t completely understand what your code is doing, so perhaps I should add some comments to your code.

FileDate = # This saves the current time under the FileDate variable, as a Java date, "yyyyMMdd") # This line doesn't do anything. The format function doesn't alter the arguments, but returns a string. So you need to assign the result to something

table = event.source.parent.getComponent("Table")
filePath = system.dataset.exportCSV('C:\SiteOverview\FileName', 1,
# The line above asks the user to save the data of the table under a fixed path.
# Note that Python uses the \ as a special character,
# so you either need to use double \\, like "C:\\My\\Directory"
# or you can use a forward / (which also works on Windows), like "C:/My/Directory"
# or you can use raw strings like r"C:\My\Directory"

if filePath != None:"file:///"+filePath.replace('\','/')) # this line again won't work due to the '\' string which even messes up the syntax highlighting at this point

Thanks for the reply and the explanation. My aim is to concentrate the 2 strings to prompt the operator of the appropriate file name to save the “.csv” file under
The 1st string is a “constant or fixed string” = product and the 2nd string is the tag “filedate” which will change with a change of date. i.e. Today the file name will be product_20180410.csv and tomorrow it will be product_20180411.csv
Am I correct in thinking that using the “system.dataset.exportCSV()” instruction that I can only use a “fixed” string, not a string derived from a tag?
I will review my code and have another attempt at a later stage as I am out on site and not in a position to make attempts now.
Again thanks for the explanation.

No, strings you get from a tag value (given the tag is a string), is just the same as a hard-coded string. Once you have the string assigned to a variable, there's no difference for the exportCSV function.

Great! Again thanks for the help. Hopefully I can get things working as I require.

I’m not sure if anybody will read this topic as it has been quite for a couple of days, but I have finally got back onto my Ignition project.
I have modified my initial code (as above) and things seem to work better but not completely
I have used “system.tag.write” function to write the formatted date value into "mydate’ .
I have saved the formatted date to a tag (mydate created as a memory tag sting) but when I try to combine strings it returns a error that it cannot concentrate a string and an ‘int’
filePath = ‘C:/My/Directory/’ +‘mydate’).value
I have also tried using the “str” function to convert ‘mydate’ to a string.
Can someone explain how I convert ‘mydate’ which comes from formatting a date to a string.
Thank you

I’d use string formatting for this:

filePath = 'C:/My/Directory/%d' %'mydate').value

%d is a placeholder for numbers, if you wanted to put in a string value you’d use %s.

Thank you for the prompt explanation
Things are looking good again