E235
E235

Reputation: 13440

How to pull data from specific column from imported CSV

I have this CSV file:

Time of Day Process Name    PID Operation   Path    Result
52:24.3 notepad.exe 4828    Process Start       SUCCESS
52:24.3 notepad.exe 4828    Thread Create       SUCCESS
52:24.3 notepad.exe 4828    Load Image  C:\Windows\System32\notepad.exe SUCCESS

I import the file to a variable:

$csvContent = Import-CSV D:\Logfile.CSV

I tried to pull out the data from the column "PID":

$csvContent[0] | select PID

but it didn't work.
enter image description here

How can I pull out the data from the PID column into variable?

Upvotes: 0

Views: 2220

Answers (1)

Kohlbrr
Kohlbrr

Reputation: 4069

There are no commas in that CSV file, and it's importing all the headers as the title of a single header.

You need to have / specify a delimiter for the elements in the file.

For example:

Time of Day,Process Name,PID,Operation,Path,Result
52:24.3,notepad.exe,4828,Process Start,,SUCCESS
52:24.3,notepad.exe,4828,Thread Create,,SUCCESS
52:24.3,notepad.exe,4828,Load Image,C:\Windows\System32\notepad.exe,SUCCESS

Upvotes: 2

Related Questions