Topic Options
#54770 - 03/29/17 10:31 AM Write variable back to CSV input file
Tom Rymes Offline
OL Toddler

Registered: 02/11/08
Posts: 43
Loc: NH, USA
I am building a watch process that grabs a CSV file via folder capture, then uses SOAP to interact with our main software package, creating an account. I would like to take the account number (saved to a Watch variable) and write it back out to the CSV file, such that I end up with the same file that was originally the input, but it now has a column that shows the account number created.

In other words, I want to use a CSV as an input and then have as the output the same CSV file with an additional column that is equal to a variable in the process.

What would be the easiest method of achieving this?

Many thanks,

Tom


Edited by Tom Rymes (03/29/17 10:31 AM)

Top
#54771 - 03/29/17 10:44 AM Re: Write variable back to CSV input file [Re: Tom Rymes]
mattila Offline
OL User

Registered: 12/17/10
Posts: 53
Loc: Minnesota, USA
Initial thought would be to do a file parser, where you would parse out a records at a time. The parser would parse out whatever your column count is if a csv, or a single line if a txt file. Handle it as a txt might be easier.

Assign the whole line content to a variable (%OrignalRecordVariable). Do your SOAP call (%SOAP_Assign_Variable).

Branch and do a Create file with the value of
%OrignalRecordVariable , "%SOAP_Assign_Variable" (Might need double quotes around the first variable).

Then send to folder using the Concatenate Files.

After the parser, you might want to do a folder capture to grab the new file.



Edited by mattila (03/29/17 10:51 AM)

Top
#54776 - 03/30/17 09:57 AM Re: Write variable back to CSV input file [Re: Tom Rymes]
Tom Rymes Offline
OL Toddler

Registered: 02/11/08
Posts: 43
Loc: NH, USA
Thanks for the reply. After posting, I had come up with the same solution. I'll give it a try and see what I get!

Top
#54778 - 03/30/17 02:30 PM Re: Write variable back to CSV input file [Re: Tom Rymes]
Tom Rymes Offline
OL Toddler

Registered: 02/11/08
Posts: 43
Loc: NH, USA
Ignore this post! It never fails: as soon as I make a post showing the full extent of my lack of understanding, I figure it out. The variable I was looking for was conveniently listed in the context menu that is available in PlanetPress. Right-click, choose variables, system, and there it is: "(%c) Job File Content".

Problem solved

...and I have already hit a wall: When creating the file, I would like to take the current data page being processed (one specific line in the CSV) as a varaible for the "CreateFile" plugin, such that it would look something like this:

%{currentpage},%{acct}

Thus, if the current line in the input file was

123,Bill,Johnson

the same line written out would be

123,Bill,Johnson,4567

(assuming that the variable %{acct} = "4567"


Edited by Tom Rymes (03/30/17 02:36 PM)

Top