Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Some questions about csv handling

$
0
0

Function Get-Answers {

Write-Host "Hi Guys"

i am new to his great website, forum and powershell. During my explorations of unknown continent of PowerShell i encountered some csv files.

While playing with them, found some questions that i can't answer myself.

Hope you guys will be able to help me in my adventures.

 

1) When using 'Import-csv' cmdlet, i am able to iterate thru rows using 'foreach' loop or selecting certain rows by providing row number like $csvVariable[4].

Question: Is there any way to iterate thru row cells? like  in 2d array in some languages--> array[3][2]

But not depending on "fixed "header names??? (i am looking something like 'foreach' or pointing at certain cell.

-right now i found some workarounds like counting NoteProperties for Imported csv variable
than knowing delimiter, know where to look in "whole" row.

2) is there a good way to join variables and write/append it as csv, instead of doing artifical string join and redirect output to file?
$var1 ="data1,data2,data3"
$var2 = "data4"
$var3 = import-csv .\file.csv

 "$var1,$var2,$var3" >> .\newFile.csv

3) is there any "Count" for header/row elements implemented?
or
better way than counting NoteProperties? 

Cause i am quiet fresh to Powershell, this is highly possible that i am reinventing something that was already done and implemented in beter way.

Regards
hermitagup

 

 

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles