1

I feel like I'm going about this the wrong way, but I've gotten myself half way there... I have a log file called DataSet.log that is formatted as:

First Dataset;24226382;2020-10-01 00:00;Second.Data.Set 1.0;0;Third.DataSet 1.0;2;Fourth.DataSet 1.0;0;Fifth.Dataset 1.0;0
First Dataset;24421469;2020-10-01 01:00;Second.Data.Set 1.0;0;Third.DataSet 1.0;4;Fourth.DataSet 1.0;0;Fifth.Dataset 1.0;0
First Dataset;24667838;2020-10-01 02:00;Second.Data.Set 1.0;0;Third.DataSet 1.0;6;Fourth.DataSet 1.0;0;Fifth.Dataset 1.0;0
First Dataset;24667839;2020-10-01 02:00;Second.Data.Set 1.0;0;Third.DataSet 1.0;1;Fourth.DataSet 1.0;0;Fifth.Dataset 1.0;0

I'm trying to convert this to a new CSV file and get it to display only the third and seventh columns. I've gotten it to display in PowerShell properly with:

Import-Csv .\DataSet.log -Header A,B,C,D,E,F,G,H,I,J,K -Delimiter ';' | Format-Table C,G

I've tried to export it as:

$testPush = Import-Csv .\DataSet.log -Header A,B,C,D,E,F,G,H,I,J,K -Delimiter ';' | Format-Table C,G

$testPush | Out-File .\test.csv

And it does create a new csv file, but it's only displaying the third column with a header of "C G." Also, that header is in A2, where A1 is blank, and A3 is populated with "- -" before the datetime from the third column populates the remaining rows... What the heck am I doing wrong?

1 Answer 1

1

Try this:

 $testPush = Import-Csv .\DataSet.log -Header A,B,C,D,E,F,G,H,I,J,K -Delimiter ';' | Select-Object C,G
 $testPush | Export-CSv -Path .\test.csv -NoTypeInformation
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.