SOLVED

Browse a CSV file with Powershell

Copper Contributor

Hello, I would like to read the contents line by line of a CSV fishie using PowerShell but I can't.
I tried this code but it doesn't show me the $Identifiant and $Nom values in ISE PowerShell console. :

$CSV = Import-CSV -Path "C:\Scripts\1234.csv" -Delimiter ";"

Foreach($Ligne in $CSV){
$Identifiant = $($Ligne."Identifiant technique du document")
$Nom = $($Ligne."Nom de fichier")


Write-host "Identifiant technique :" $Identifiant "Nom du fichier :" $Nom
}

 

I have this in output :

444456464_0-1656414740584.png

 

And my CSV file is like this :

Identifiant technique du documentNom de fichier
11111111111111111111.json
22222222222222222222.json
33333333333333333333.json
44444444444444444444.json
55555555555555555555.json
66666666666666666666.json
77777777777777777777.json

 

Can you help me please ? :( Thanks in advance ! 

1 Reply
best response confirmed by 444456464 (Copper Contributor)
Solution

Could you try this?

$Identifiant = "$($Ligne).'Identifiant technique du document'"
$Nom = "$($Ligne.)"N'om de fichier'"
Write-Host "Identifiant technique : $(Identifiant) Nom du fichier : $($Nom)"