Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:11:58+00:00 2026-06-17T04:11:58+00:00

Currently, I have a system which creates a delimited file like the one below

  • 0

Currently, I have a system which creates a delimited file like the one below in which I’ve mocked up the extra line feeds which are within the columns sporadically.

Column1,Column2,Column3,Column4

Text1,Text2[LF],text3[LF],text4[CR][LF]

Text1,Text2[LF][LF],text3,text4[CR][LF]

Text1,Text2,text3[LF][LF],text4[CR][LF]

Text1,Text2,text3[LF],text4[LF][LF][CR][LF]

I’ve been able to remove the line feeds causing me concern by using Notepad++ using the following REGEX to ignore the valid carriage return/Line feed combinations:

(?<![\r])[\n]

I am unable however to find a solution using powershell, because I think when I get-content for the csv file the line feeds within the text fields are ignored and the value is stored as a separate object in the variable assigned to the get-content action. My question is how can I apply the regex to the csv file using replace if the cmdlet ignores the line feeds when loading the data?

I’ve also tried the following method below to load the content of my csv which doesn’t work either as it just results in one long string, which would be similar to using -join(get-content).

[STRING]$test = [io.file]::ReadAllLines('C:\CONV\DataOutput.csv')
$test.replace("(?<![\r])[\n]","")
$test | out-file .\DataOutput_2.csv

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:12:00+00:00Added an answer on June 17, 2026 at 4:12 am

    Nearly there, may I suggest just 3 changes:

    • use ReadAllText(…) instead of ReadAllLines(…)
    • use -replace … instead of .Replace(…), only then will the first argument be treated as a regex
    • do something with the replacement result (e.g. assign it back to $test)

    Sample code:

    [STRING]$test = [io.file]::ReadAllText('C:\CONV\DataOutput.csv')
    $test = $test -replace '(?<![\r])[\n]',''
    $test | out-file .\DataOutput_2.csv
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a properties file which currently contains system names and ip addresses. What
Currently I have an algorithm which somewhat looks like web-spiders or file search systems
I currently have a system in which one rails 2.3.2 has a database with
Currently we have a system which we paid for that pushes information into Excel
I currently have a class file with the following enumeration: using System; namespace Helper
Currently I have one application in which I am able to access .mdb or
In a system I'm currently working on, I have many components which are defined
I currently have a NHibernateHelper class which creates a session factory. I keep recieving
I write an application which creates a JSON File following the below structure: {
I'm currently have a program which creates a list of all MAC addresses and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.