Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Export results to bat file with new lines

aehrenwo
11 - Bolide

I am attempting to output dynamic results into a batch file to execute after it is produced. 

 

The results that I see in the workflow have new lines however the output is not reflecting this new lines and I am not sure what output format I should use to make sure these appear. 

 

As a result of the new lines not being included the batch files is failing. 

 

Any suggestions? 

 

See the attached workflow

8 REPLIES 8
darryl5280
10 - Fireball

This looks strange but it is simple solution.

 

Change:

[Code1] + "xxx" + [Code2] + "xxx" + [Code3]

 

To:

[Code1] + "
xxx" + [Code2] + "
xxx" + [Code3]

aehrenwo
11 - Bolide

I actually don't need the xxx if I use this method as the Regex becomes redundant. 

 

[Code1] + "
"
+ [Code2] + "
"
+ [Code3]

 

However, when I do this and export the results as a pdf.bat file using the "csv" option 

 

It produces a file that looks like this all on ONE line with no new lines. any suggestions? 

 

cd "C:\Program Files\wkhtmltopdf\bin\"wkhtmltopdf.exe "https://www.google.com/search?q="Adam+Ehrenworthcorruption+cases&num=50" "C:\Users\SA-JJC-HCC_Ops\OneDrive - JNJ\workflows\TPIGoogle\pdf\000001.pdf' pause

darryl5280
10 - Fireball
Spoiler
I would just skip the writing out the BAT file and send it to the "Run Command" tool so you can execute it.

Here is my BAT file commands in the Formula Tool:

Batch file created with a Formula tool.jpg

 

And the field contain the code is passed into the "Run Command" tool and the "Run Command" saves it.
Just the Temp directory is used here.

Batch File Setup in the Command Tool.jpg

darryl5280
10 - Fireball

I just upgraded your Workflow use the "Run Command" writes out the BAT file and then Executes it, and I added the Standard Output as a text file to read it to see the results of the BAT file.

 

I have your real BAT Code in a close Container so we can and everyone else can run it,  But for your just enable the Container show yours.

 

I hope this works,as its always helpful to have a test version working, and just have to match the syntax to match yours work.

aehrenwo
11 - Bolide

Ok - I think I am following the logic. Let me play around with it over the weekend and I will let you know if I get it working. 

 

Thanks!


Adam

danilang
19 - Altair
19 - Altair

Hi @aehrenwo 

 

When you're writing to bat files, you need to include the complete Windows line ending CRLF, ASC(13)ASC(10).  \n(Asc10) only includes the LF. 

 

you can either change your regex to 

 

REGEX_Replace(Code, 'xxx', "\r\n")

 

Or change your formula to 

[Code1] + CharFromInt(13) + CharFromInt(10) + [Code2] + + CharFromInt(13) + CharFromInt(10) + [Code3]

 

This also removes the need for your regex in the same tool.

 

In both cases your line breaks will be preserved.  

 

Dan

darryl5280
10 - Fireball

Yes, I understand, it took me a long to develop this method, and it introduces new concepts of using the Temp folder and passing in the BAT file into the "Run Command".  There are 2 magic tricks used.

 

Magic Trick #1

At run time Alteryx changes this: "%Engine.TempFilePath%"

To: "C:\User\[UserID]\AppData\Local\Temp\Engine_13592_efc648be24f64102a7557b46cc033531_\”

 

Magic Trick #2

And the Input to the "Run Command" it magically picks the field name containing the BAT commands, but with other tools you specify the Field Name, so I just restrict the fields passed in with a "Select" tool to just one field with the BAT Commands and once i got it working I was so happy I didn't want to mess with it anymore.

 

When you run the workflow look in the results window, and right click on one of file outputs, and pick "Open Folder".  Then you can see your 2 files, "PDF.ba"t and "PDF.txt" as they will stay in the Temporary folder for a few minutes. Then they will be deleted.  As for me thinking about a idea overnight, always brings me more insights the next morning.

 

Good Luck

And I happy to answer any of your questions.

aehrenwo
11 - Bolide

THANK YOU!   got this working end to end with MS Flow and I am getting resutls in a zip file automatically ... 

 

so cool. :) 

 

 

Labels