Convert DateTime value to string for csv file

I have a datetime object from an ignition edge gateway tag historian being retrieved and put into a csv file. The datetime itself is still showing up as a unicode value instead of a string. I do have str() around the datetime value on rung 35 but no matter what I do I can't get the unicode value to be displayed as a string. I have tried using the datetime module and astype(str) and it still won't convert it.

Unicode is already a string, but that isn't the issue here. You are printing a List representation not a "String".

If you were accessing the element in the list, then it would print without the unicode identifier.

now = u'' + str(system.date.now())

listNow = [now]

print listNow
print now

Output:

Jython 2.7.2 (default:000000000000, May 20 2021, 14:52:22)
[OpenJDK 64-Bit Server VM (Azul Systems, Inc.)] on java11.0.13

>>> 
[u'Thu Dec 08 09:56:25 EST 2022']
Thu Dec 08 09:56:25 EST 2022
>>> 

BTW, posting screen shots of code, makes it difficult to help, they're hard to read and if we want to test your code we have to retype it. Use the preformatted text option </>.

In your code try this:

for row in xrange(AIdatasetF.rowCount):
    outputRow = AIdatasetF.getValueAt(row,0) + ','

Correct about sending the code...will do next time.

The code you sent at the end worked perfect! I did end up getting it to work by leaving that line of code for outputRow as a list. Then I had to add a few lines to convert the list to a string by using the .join function but this way is much easier!