Upland OL User community

Text File Extract to CSV Export

Hello I am very new to Planet Press Connect.

I have one text file with multiple purchase orders. Each purchase order has item detail.
I have created a data model with 2 extraction steps (and a repeat step) that will separate the text file by purchase order and item detail.
I need to export the text file to separate CSV files. So if there are 3 purchase orders within the text file, I need 3 separate CSV files.
The 2 extraction steps have created 2 data tables named “record” and “record.itemdetail”.
What I don’t know is how to combine the data table “record” and the data table “record.itemdetail” as one record line within the CSV file.
I believe I can accomplish through Javascript but not sure of how to loop correctly.

For example:

Import - TEXT FILE

PO Header
PO#: 12345
Ven#: A9999
Address: 123 Twig St

PO Detail
Item#: 77777
Description: Box of Cereal
Qty: 5

Export - CSV FILE (What I would like the output to look like below)

PO#, Ven#, Address, Item#, Description, Qty
12345, A9999, 123 Twig St, 77777, Box of Cereal, 5

Thank You,

Take a look at this post, which explains how to write a csv from a post-processor step in the DataMapper. You can search for other post-processor information on this forum using the search function at the top of the page.

Thank you Phil. I have the javascript in place and the datamapper uploaded to the workflow. Could you point me in the direction of how to process the file from workflow? I am also new to the Connect plugins and not sure how to setup the workflow process.

Not quite sure what you’re asking… you want to feed the CSV back to the Connect? Why did it need to be converted to CSV, then?

Sorry for the confusion. I want to automatically receive 1 (as400) text File into a folder and convert it into 3 separate (CSV) files.

I have

  • created the datamapper through Connect Designer
  • added a script to the postprocessor
  • uploaded the datamapper to the workflow

I am not sure what my next step is to automatically convert the as400 files.

Thank you, Tim

In Workflow, Folder Capture->Execute Data Mapping->Delete Plugin.


You should also watch the online tutorials for Workflow, they explain in broad strokes how it works and what it is used for.

Thank you Sharne and Phil!!! I have one last question. Would one of you know how to incorporate a variable in the file name?

What I currently have is static:
var fileOut = openTextWriter(“D:\\Test\\ExportFile.csv”);

I would like to put a mapped field into the filename:
var fileOut = openTextWriter(“D:\\Test\\PO” + [“PONumber”] + ”.csv”);

So the result would be:

I think I can add another step in Connect Designer to set the variable but I am not sure if that is the best approach.

Since your script runs in the PostProcessor, you have access to the whole array of your datamodel

var poNumber = record.fields.PONumber;
var fileOut = openTextWriter(“D:\\Test\\PO” + poNumber + ”.csv”);

Thank you Hamel! And to Phil and Sharne! Everything works perfectly.