bsharath
asked on
How can i delete blank rows in a text file.
Hi,
I want to delete the blank rows in the text file.I dont want to put the data to any other file edit and replace it to the text file.Any built in way or a script to run on the text file to remove blank lines.
Regards
Sharath
I want to delete the blank rows in the text file.I dont want to put the data to any other file edit and replace it to the text file.Any built in way or a script to run on the text file to remove blank lines.
Regards
Sharath
ASKER
What filename should i save this
If you want it as a script do this. I was just expecting you do to it at the prompt
Name = Remove-Spaces.ps1
### Cut/Paste ###
$param ($file)
$data = get-content $file
$data | ?{($_)} | out-File -enc ASCII $file
###############
From the PS Prompt
PS> C:\MyPathtoScript\Remove-S paces.ps1 c:\MyFilePath\FileName.txt
This will require Powershell be installed. I reread your requirements and I noticed you wanted this built in. Powershell does need to be installed. I can do this in batch but you will need a temp file.
Name = Remove-Spaces.ps1
### Cut/Paste ###
$param ($file)
$data = get-content $file
$data | ?{($_)} | out-File -enc ASCII $file
###############
From the PS Prompt
PS> C:\MyPathtoScript\Remove-S
This will require Powershell be installed. I reread your requirements and I noticed you wanted this built in. Powershell does need to be installed. I can do this in batch but you will need a temp file.
Or simply export this txt file into Excel using
Data>Import External Data> Import Data> ... browse to ur txt file.. it should import ur data into rows and ..
Now go to EDIT>Go To > Click on Special > select Blanks and click ok .. all the blank cells in a row would be selected..
now u can delete them... just hit the DEl key
Data>Import External Data> Import Data> ... browse to ur txt file.. it should import ur data into rows and ..
Now go to EDIT>Go To > Click on Special > select Blanks and click ok .. all the blank cells in a row would be selected..
now u can delete them... just hit the DEl key
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$file = "PathtoYourFileNameHere"
$data = get-content $file; $data | ?{($_)} | out-File -enc ASCII $file