Forum Discussion

444456464's avatar
444456464
Copper Contributor
Jun 28, 2022
Solved

Browse a CSV file with Powershell

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 :

 

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 ! 

  • 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)"

1 Reply

  • 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)"

Resources