Process a csv and append to a txt file – help needed!

by Sep 13, 2014

Hi,

I'm new here and I'm hoping someone can
help and show off their PowerShell skills at the same time!

I want to create a script that
processes a CSV file and pulls data from certain columns and rows and
appends them to a TXT file. The text file is actually intended for
import to Ventura 10 and so must contain some standard mark up too.
Like this…

 

@NO. = 3.

@DESCRIPTION = 1576 CORSINI MAIL. A fine entire Paris to "Filippio Corsini in London" dated 20 August 1576. (Ref<N>83098)

@PRICE = <156>185.00


In the example above '@NO. =' should increase by 1 each time a row is processed. '@DESCRIPTION =' is direct from a CSV column. 'Ref<N>' is direct from a CSV column. '@PRICE' = is direct from a CSV column. So, I'd like the script to:- * ask user to input variable * use that variable to determine which rows to process by matching it in the relevant column e.g. List number 141 * process each row and append data from the description, ref number, and price columns as above * add the necessary Ventura mark up


From the research I've done so far I think Import-Csv, Where-Object, and Out-File will be used but I don't know enough to get started. If someone could provide me with a basic template I could take it from there. Many thanks!