computing
  • 2

Solved Remove CR/LF That Are In Between Double Quotes.

  • 2

I had a large comma delimited, text quoted text file that I need to modify. Some of the data has a CR/LF within its double quotes. This happens all through out the file. Here is an examle.
“123”, “bla bla CR/LF bla bla”, “Alpha 123”, “signature CR/LF Tom Jones”, …, CR/LF

I need only the CR/LF’s removed that are within the double quotes, the ones at the end of the line must stay (they are outside of the double quotes).

Any help would be much appreciated!

Share

1 Answer

  1. I just happen to have PowerShell ISE up, so here’s a PowerShell solution.

    [string]$line = ""
    Get-Content ".\test.csv" | ForEach-Object {
      if (!([Regex]::Matches(($line += $_), '"').Count -band 1)) { $line; $line = "" }
    }

    How To Ask Questions The Smart Way

    • 0