title: How to import csv replace characters and export csv that is saved in blob in powershell
body: <p>I am very new to powershell. I am trying to replace characters in a csv that is saved in blob storage. Take the file from one folder, do the replace and save in another.</p>
  
  <p>I have 2 sets of code, one for replacing the characters and one for creating blob context. However, I am unsure how to put them together to perform the task. Meaning what do I use instead of 'import-csv' and 'set-content' and how do I tell it to do this for each file in the folder? Any advice would be appreciated.</p>
  
  <pre><code>$dest = "C:\test\Test - Copy\"
  
  Function RemoveStripScrape ($CsvFileName, $csvLoc)
  {
      $CsvFile = $csvLoc + $CsvFileName + ".csv"
      $ExportLoc = $csvLoc + $CsvFileName + ".csv"
  
      $Csv = Import-Csv $CsvFile 
  
      $regex = '(?&lt;!"),|,(?!")'
      $regex1 = '(?&lt;!\r)\n'
  
      $Csv | Select-Object * |ConvertTo-Csv -NoTypeInformation | %{$_ -replace $regex,' '} |%{$_ -replace $regex1, ' '} | Set-Content $ExportLoc 
      }
  
  $ens = Get-ChildItem $dest -Recurse -include Let*.csv
  foreach($e in $ens)
  {
      $e.Basename
      RemoveStripScrape -CsvFileName $e.BaseName -csvLoc $dest
  } 
  </code></pre>
  
  <p>get context:</p>
  
  <pre><code>$azurepw = ConvertTo-SecureString "xyz" -AsplainText -Force
  $cred = New-Object -typename pscredential -argumentlist "xyz@xyz.com",$azurepw
  Login-AzureRmAccount -credential $cred | Out-Null
  
  $resourcegroup = "xyz"
  $storageaccountname = "xyz"
  
  $storageaccountkey = `
      (Get-AzureRmStorageAccountKey `
      -ResourceGroupName $resourcegroup `
      -Name $storageaccountname).Value[0]
  
  $sourceContext = New-AzureStorageContext $storageaccountname $storageaccountkey
  $container = "xyz"
  
  $FileDate = $($(Get-Date).ToString('yyyyMMdd'))
  $SourceFileName = "*activity*.csv"
  $SinkFileName = "processed_$($FileDate).csv"
  $BlobSourceFileNamePath = "Data/Revenue/Archive/CorethreeNew/$($SourceFileName)"
  $BlobSinkFileNamePath = "Data/Revenue/Archive/CorethreeNew/Processed/$($SinkFileName)"
  #$BlobArchiveSinkFileNamePath = "Data/Revenue/Archive/CorethreeNew/Archive/$($SinkFileName)"
  </code></pre>