E9.2 Export a table into a text/csv file

Jedi_wrenched

Member
Hi all,
I'm relatively new to Orchestrator, could you please suggest is it possible to use Orchestrator to export a table content into a text file?
I've already created a data request and it returns the data I need from the table, but I can't understand how I can direct it into a file.
Thank you in advance!
Cheers
 
What version of tools are you on?? If you're on mine or earlier, you might have to resort to using a script to get the text into a format you want, and then perhaps a message or FTP connector call to toss the file somewhere useful. If you're on release 22 or above there's a neat function that a colleague showed me the other day involving opening up the Orchestration Outputs, and then you can select File output from a Data Request. It was really nifty, I wish we had it on our current version!
 
I am quite sure a bit of groovy code could create a file any way you want it. We have code posted hee to loop thru the jsonSlurper data result set, the links for outputting a csv are numerous on the interweb.
 
DaveWagoner, our tools release is 9.2.5.3, so lower than yours, I guess we don't have it either.

Stank1964, thanks for the tip, I'll explore this option.
 
Found this documentation:


Here, you just define your Orchestrator output as a csv file, easy as pie.

We don't have it in our TR though. I think the screenshot in the documentation are what Dave wrote above, about this nifty feature in newer TRs.

That's actually pretty cool and simple, just what we need. Time to upgrade, I guess.
 
Back to the groovy way to create a .csv file.

In the end of the Orchestration, I went to Manipulate Output and added the following code:

Code:
def json = new JsonSlurper().parseText(jsonOut)
 
 // Extract the "rowset" array
def rowset = json.TEST_Export_F0101.rowset


def filePath = "\\\\SERVER\\Users\\Public\\Documents\\EDI\\F0101.csv"
// The path definitely exists, checked and double-checked; everyone in the network should have access to it
// Create the CSV file
def newFile = new File(filePath)
newFile.createNewFile()
    newFile.withWriter { writer ->
    // Write the header
   writer.writeLine(rowset[0].keySet().join(','))
    // Write the rows
   rowset.each { row ->
       writer.writeLine(row.values().join(',')) }
    }

orchestrator produces no error running this, but I didn't find the file where I expected it to be

I tried to read back from the file I've just created, so I added this after writing all the content to my file:

Code:
    String fileContents = new File(filePath).text;

Peeked into the fileContents value, and it's correct! fileConents is what I read back from the file, and it's what I expect the file content to be.
So the file did get created somewhere, but definitely not where I expected it, namely not here:

\\SERVER\Users\Public\Documents\EDI\

I played a bit with paths, for example, tried local paths, for example:

C:\temp\F0101.csv

And got the same result, no errors, file got created somewhere I don't know where, but not in my C:\temp

So my questions:

Where are Orchestrations actually run? Where can I try and find the file I created (if it was created, but taking into account I was able to read back from it it was)? How do I direct it to a shared network location?

Thanks in advance! I hope that will help someone else as well in the future
 
DaveWagoner, our tools release is 9.2.5.3, so lower than yours, I guess we don't have it either.

Stank1964, thanks for the tip, I'll explore this option.
Custom service request using groovy script works great. Can write file to anywhere on the network.
 
Back
Top