Newbie – Import CSV and manupulate data and export
We have a raw csv file that has a potential of having a debit and credit in the same line. It has a total field as well, which is accurate, however, I need to process each line of the file and determine if the total is great than or equal to 0, it goes to Debit, else it goes to Credit.
here is what i am starting with
This is what I am trying to get to:
here is the code
$data = Import-Csv -Path $csvFile.FullName | Select GL, vAcctDescription, Debit, Credit, Total
$data | foreach-object { $_ | if ($data.Total -gt 0)
{
[double]$data.Crebit = [double]$data.Total
}
else {
{
[double]$data.Credit = [double]$data.Total
[double]$data.Credit * 1
}
}
}
We have a raw csv file that has a potential of having a debit and credit in the same line. It has a total field as well, which is accurate, however, I need to process each line of the file and determine if the total is great than or equal to 0, it goes to Debit, else it goes to Credit. here is what i am starting with This is what I am trying to get to: here is the code $data = Import-Csv -Path $csvFile.FullName | Select GL, vAcctDescription, Debit, Credit, Total
$data | foreach-object { $_ | if ($data.Total -gt 0)
{
[double]$data.Crebit = [double]$data.Total
}
else {
{
[double]$data.Credit = [double]$data.Total
[double]$data.Credit * 1
}
}
} Read More