How to read tabbed delimitted csv file line by line using Powershell ?

Copper Contributor

Hi ,

I have file with many rows . Since the size of limitations I want to read only line by line and put into any array . Please assist .

3 Replies

@Raghava Tiruchanur This splits every line by the tab character and fills the $total array with a ; delimiter 

 

 

$total=@()
foreach ($line in Get-Content D:\Temp\file.txt) {
    $content=$line.Split("`t") -join ';'
    $total += $content
}

 

The contents of my test file.txt file are:

 

test1 test2 test3 test4
test5 test6 test7 test8

 

Did this work out for you?