I am working on a PowerShell program to parse some financial files we are getting. We get the data in one txt file and I need to export it as a csv in specified rows and columns. I have gotten the txt file parsed, and all prepped, so I need to walk through each row in the parsed file and create about 15 new columns in a new file.
Something like that, where the new file is made up of more columns of data, made up of the data from the parsed file, plus static bits that have to be there. I have used PowerShell a bit, but all for actions and tasks, never to parse and create files like this, so I am sort of at a loss.
There are several way sto accomplish your task. Here is one possibility.
Import-Csv "D:\New Text Document.txt" |
A = "Static text"
B = [int]$_.A + [int]$_.B
C = ""
D = ""
E = ""
F = $_.C + ".0000.000.1"
G = ""
H = ""
I = [string]([int]$_.C + [int]$_.D) + "477883.0000.334"
} | Export-Csv Output_File.csv -NoTypeInformation
The topic ‘Parsing data into a .csv file’ is closed to new replies.