Home > Mobile >  Add character between column combine in a CSV
Add character between column combine in a CSV

Time:10-22

I'm looking for the correct syntax to add some (") between my variable. I need something like that :

"firstname","lastname","email","",""

Here is the first script I have :

foreach($line in Get-Content .\extract.csv) 
{ $firstname = $line.split(';')[0] 
$lastname = $line.split(';')[1] 
$email = $line.split(';')[2] 
$newLine = "$firstname - $lastname - $email" 
echo $newLine }

I'm really new in scripting and I'm a bit lost with all these (') (")

My second question is : I need to extract my data only from the second row and ignore the first one, can you help me for this too ?

Thanks !

CodePudding user response:

Have you try escaping your " and ' ?

In powershell you can use backtick ` (AltGr 7) or doubling the char to do so :

Example :

Write-Host(" `" ")
Write-Host(" "" ")

Please add more code if this doesn't solve you issue !

  • Related