How to read no. of records in a csv file using powershell?
hi,
the problem asking not simple. have array say, $filearray having names of csv file in particular folder without full path. e.g. $filearray[0] = "remmitance.csv". records in "remmitance.csv" comma seperated but spread over more 1 line. wanted read no. of lines in file through powershell script. did :
$a=get-content $filearray[0]
$total = $a.length
but issue get-content read file if full path specified.
now, have variable $fromdir, has path of file. i wrote following command:
$var= $fromdir + "\" + $filearray[0]
now $var has full path of file.
i tried
$a = get-content $var
$total=$a.length
still not working me. please help. note cannot keep array of of filenames full path due logic need implement further.
please help. thanks
try using join-path instead of putting path yourself. say:
" is comma seperated but spread over more 1 line"
do mean 1 record exist on more 1 line? if case, use import-csv instead of get-content.
Windows Server > Windows PowerShell
Comments
Post a Comment