Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value from CSV file on specific coordinate

Tags:

powershell

csv

I need to extract data from CSV file based on coordinates entered by user, so let's say that user enter next values:

$rowPosition = 5
$columnName = 'testColumn'

and I need to get value from 5th row in column testColumn.

I know how to extract just one column, but I need further filtering with row position.

like image 791
veljasije Avatar asked Feb 16 '26 19:02

veljasije


1 Answers

First, I created two variables consisting column name and row position in desired CSV file.

$columnName = 'testColumn'    
$rowPosition = 2

Then I just access to specific cell at this way:

#Load .csv file into variable
$csvFile = Import-csv .\Desktop\counter.csv -Delimiter ','

echo $csvFile.$columnName[$rowPosition]
like image 50
veljasije Avatar answered Feb 19 '26 06:02

veljasije



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!