Link to home
Start Free TrialLog in
Avatar of Fr. Vandecan
Fr. VandecanFlag for Belgium

asked on

how to handle - import-csv results

Dear experts
I have this command $Items = Import-Csv -path "$CsvFile" -Encoding UTF8 –delimiter ";"

This work pretty well so I can access the collection by having the fieldnames etc.... ($Items.<fieldname> is OK)

BUT how to have a global view ? How to know for $Items, the number of elements?


Tks.
Avatar of oBdA
oBdA

$Items.Count

Open in new window

Avatar of Fr. Vandecan

ASKER

$items.count return nothing.

 write-host $items
@{IDENTIFIANT=900000003; TITLE_CODE=; TITLE_NAME=; CONTRAT_NB=900000003; NAME=AO; FIRSTNAME=Stagiaire; SEXE=; NATIONAL_ID=; STREET=; STREET_NR=; STREET_BOX=; CITYCODE=; CITY NAME=; COUNTRY NAME=; PHONE_PROF=; GSM_PROF=; EMAIL_PROF=stAO@daoust.be; BIRTHDATE=; NATIONALITY NAME=; LANG=; WORKERLANG NAME=; TRY_DATE=; ENTRY_DATE=20171130; OUT_DATE=; CONTRAT_TYPE=; CONTRAT_TYPE_NAME=; FTE=; FUNCTION=Stagiaire; AGE=; CODE_DEPARTEMENT=; DEPARTEMENT=; IDENTIFIANT_RESPONSABLE=; LOGIN_RESPONSABLE=sgoossens; RESPONSABLE=; LOGIN=stao; CODE_EMPLOYEUR=51300; CODE_SITE=AO; SITE=; EmployeeName=Stagiaire AO; SignaletiqueInsert=20171130; SignaletiqueUpdate=; AddressInsert=; AddressUpdate=; AffectationInsert=; AffectationUpdate=; ContractInsert=; ContractUpdate=; GAP=; Matchbox=; SMILE=; Intranet=; Desktop=; Laptop=; Carte_De_visite=; telephone=; GSM=; Smartphone=; Signal=; VPN=; clee_jobcenter=; ProxBudget=; Analytique1Code=; Analytique2Code=; IN=TRUE; OUT=}

write-host $items.count

return nothing
And of course you can just dump everything with $items | format-table -auto or $items | format-list, to see what is in the collection.
That is a single object, no collection. @($Items).Count works though. It forces the content to be an array, and that array always has a Count member.
yes indeed Qlemo, but I want to have the number of items on this collection/hashtable what is this object.
@($Items).Count report 1 not the count of all elements....
That is a different beast. You want to know the number of (custom) properties of that custom object ...
A hashtable would allow for counting, e.g. @{a=1;b=2}.Count.
Ok. I'm still lost....
how may I know the number of custom properties that has a custom object? (from the import-csv cmdlet) Purpose is dataquality check (see if I have the number of col that I expect)
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your'e brillant !