Remove New line Char from Text file
Moderator: DosItHelp
Remove New line Char from Text file
Hi,
In a Comma delimited file , 1 special new line char is coming.
so while reading the file its creating new row from that point,
pls help me to remove that char , i hv searched on internet but didnt find anything.
Its an urgent, pls reply.
thanks in advance
[img]D:\spcl_char.png[/img]
In a Comma delimited file , 1 special new line char is coming.
so while reading the file its creating new row from that point,
pls help me to remove that char , i hv searched on internet but didnt find anything.
Its an urgent, pls reply.
thanks in advance
[img]D:\spcl_char.png[/img]
Re: Remove New line Char from Text file
It would seem that the easiest method is to edit the file and remove the character...
Re: Remove New line Char from Text file
can it be done by batch script, as its needs to be automated.
Re: Remove New line Char from Text file
This will remove a lone CR
EDITED:
EDITED:
Code: Select all
@echo off
for /f "delims=" %%a in (sample.csv) do cmd /c (>>"newfile.csv" echo %%a)
Re: Remove New line Char from Text file
Hi, Its removing the whole line, but i just need to remove the special Char.
as i need to load the line.
Pls suggest.
as i need to load the line.
Pls suggest.
Re: Remove New line Char from Text file
I tested it here and it worked. One problem is that I don't have your file so I can't test it and see what the problem is.
Re: Remove New line Char from Text file
here is the data problem is in 1101104/5/6
"1009101","90",02/01/2010,04/30/2011,"00000",2010-04-02-16.33.00.000000,"257",2011-02-26-13.02.00.000000,"087",02/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",25000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",0.00,"W"," ",0.000000,0.00,0.0000,0.00,0.0000,0.00,"F",28.500000,0.000000,0.0000,"Q",0.00,"Q",45,60,"Q","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,," ","S","Y","N",100.00,0.00,"Y","N",100.00,"A",,,0.,0.,0.00,0.," ",5000000.00,0.0000,0,0,0,0.,0.,0.,0.00," ",09/01/2012,"01","90","10","O","N","30","N","N",0.00," ",1,0,,,0.00,0.00," ",0,"N",2010,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"09","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,17500000.00,70.000000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1009102","90",04/01/2010,03/31/2011,"00000",2010-04-29-19.10.00.000000,"125",2010-04-29-19.10.00.000000,"125",04/01/2010," ",,,0.00,"N",0.00,"90",100.000000," ",10000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",0.00,"W"," ",0.000000,0.00,0.0000,0.00,0.0000,0.00,"F",27.000000,0.000000,0.0000,"M",0.00,"M",45,60,"M","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,," ","S","Y","N",90.00,0.00,"Y","N",90.00,"A",,,0.,0.,0.00,0.," ",5000000.00,0.0000,0,0,0,0.,0.,0.,0.00," ",09/01/2012,"01","90","10","O","N","30","N","N",0.00," ",1,0,,,0.00,0.00," ",0,"N",2010,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"09","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,10000000.00,40.000000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1011101","90",11/01/2010,10/31/2011,"00000",2010-12-11-08.23.00.000000,"087",2010-12-23-13.18.00.000000,"087",11/01/2010," ",,,0.00,"N",0.00,"90",100.000000," ",15000000.00,10000000.00,0.00,0.00,3,44,"M",0.00,15000000.00," ","N",0.00,,"N",22535570.00,"W"," ",21.344600,5063291.87,0.0000,5063292.00,0.0000,0.00,"F",21.000000,0.000000,0.0000,"Q",0.00,"Q",15,15,"Q","E",90,15,"9","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,," ","I","Y","N",90.00,0.00,"Y","N",90.00,"I",,,0.,0.,5063291.87,0.," ",0.00,0.0000,0,0,0,0.,0.,0.,5063291.87," ",09/01/2012,"AC","90","41","O","N","30","N","N",0.00," ",1,0,,,0.00,15000000.00," ",0,"N",2010,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"11","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,15000000.00,14250000.00,95.000000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1012103","90",12/01/2010,11/30/2011,"00000",2010-12-27-12.02.00.000000,"087",2010-12-27-12.02.00.000000,"087",11/01/2010," ",,,0.00,"N",0.00,"90",100.000000," ",10000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",0.00,"W"," ",0.000000,0.00,0.0000,0.00,0.0000,0.00,"F",28.000000,0.000000,0.0000,"Q",0.00,"Q",45,45,"Q","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,," ","S","Y","N",100.00,0.00,"Y","N",100.00,"I",,,0.,0.,0.00,0.," ",1000000.00,0.0000,75,83,0,0.,0.,0.,0.00," ",09/01/2012,"AC","40","10","M","N","30","N","N",0.00," ",1,0,12/01/2010,11/30/2011,0.00,0.00," ",0,"N",2010,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"05","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,3750000.00,37.500000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1101102","90",01/01/2011,12/31/2011,"00000",2011-03-29-11.24.00.000000,"087",2011-03-29-11.24.00.000000,"087",03/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",150000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",0.00,"W"," ",0.000000,0.00,0.0000,0.00,0.0000,0.00,"F",25.000000,0.000000,0.0000,"M",0.00,"M",45,45,"M","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","S","Y","N",100.00,0.00,"Y","N",100.00,"A",,,0.,0.,0.00,0.," ",0.00,0.0000,0,0,0,0.,0.,0.,0.00," ",,"AC","16","10","M","N","30","N","N",0.00," ",1,0,01/01/2011,12/31/2011,0.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"05","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,120000.00,80.000000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1101103","90",01/01/2011,12/31/2011,"00000",2011-04-01-10.01.00.000000,"466",2011-04-01-16.23.00.000000,"087",03/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",25000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",24000000.00,"W"," ",0.000000,4800000.00,0.0000,0.00,0.0000,0.00,"F",28.500000,0.000000,0.0000,"Q",0.00,"Q",60,104,"Q","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","I","N","N",0.00,0.00,"Y","N",100.00,"A",,,0.,0.,4800000.00,0.," ",1250000.00,0.0000,0,0,0,0.,0.,0.,0.00," ",09/01/2012,"AC","54","10","O","N","30","N","N",0.00," ",1,0,,,0.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"17","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,5000000.00,20.000000,0.000000,0.00,0.00,0.00,0.00,,"N","20% Quota Share of up to $25mm","",""
"1101104","90",01/01/2011,12/31/2011,"00000",2011-04-01-11.01.00.000000,"466",2011-04-06-19.26.00.000000,"087",03/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",7500000.00,12500000.00,0.00,0.00,4,52," ",0.00,0.00," ","N",0.00,,"N",24000000.00,"W"," ",5.500000,1650000.00,0.0000,0.00,0.0000,0.00,"N",0.000000,0.000000,0.0000,"Q",0.00,"Q",91,91,"Q","A",60,60,"9","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","I","N","N",0.00,0.00,"Y","N",100.00,"A",,,0.,0.,1650000.00,0.," ",0.00,0.0000,0,0,0,0.,0.,0.,1650000.00," ",10/01/2011,"AC","54","41","O","N","30","N","N",0.00," ",1,0,,,18000000.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"17","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,6000000.00,80.000000,0.000000,0.00,0.00,0.00,0.00,,"N","80% of $7.5mm xs $12.5mm
Abs Max Loss $18mm (2 full reinstatements) at 80%","",""
"1101105","90",01/01/2011,12/31/2011,"00000",2011-04-01-11.08.00.000000,"466",2011-04-06-19.27.00.000000,"087",03/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",5000000.00,20000000.00,0.00,0.00,4,52," ",0.00,0.00," ","N",0.00,,"N",24000000.00,"W"," ",2.000000,510000.00,0.0000,0.00,0.0000,0.00,"N",0.000000,0.000000,0.0000,"Q",0.00,"Q",91,91,"Q","A",60,60,"9","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","I","N","N",0.00,0.00,"Y","N",100.00,"A",,,0.,0.,600000.00,0.," ",0.00,0.0000,0,0,0,0.,0.,0.,600000.00," ",10/01/2012,"AC","54","42","O","N","30","N","N",0.00," ",1,0,,,12000000.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"17","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,4000000.00,80.000000,0.000000,0.00,0.00,0.00,0.00,,"N","80% of $5mm xs $20mm
Abs Max Loss $12mm (2 full reinstatements) at 80%","",""
"1101106","90",01/01/2011,12/31/2011,"00000",2011-08-25-10.09.00.000000,"087",2011-08-25-10.09.00.000000,"087",08/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",7500000.00,12500000.00,0.00,0.00,4,52," ",0.00,0.00," ","N",0.00,,"N",24000000.00,"W"," ",5.500000,1650000.00,0.0000,0.00,0.0000,0.00,"N",0.000000,0.000000,0.0000,"Q",0.00,"Q",91,91,"Q","A",60,60,"9","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","I","N","N",0.00,0.00,"Y","N",100.00,"A",,,0.,0.,1650000.00,0.," ",0.00,0.0000,0,0,0,0.,0.,0.,1650000.00," ",10/01/2012,"AC","54","41","O","N","30","N","N",0.00," ",1,0,,,18000000.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"17","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,6000000.00,80.000000,0.000000,0.00,0.00,0.00,0.00,,"N","80% of $7.5mm xs $12.5mm
Abs Max Loss $18mm (2 full reinstatements) at 80%","",""
"1102101","90",02/01/2010,01/31/2011,"00000",2011-10-03-08.51.00.000000,"087",2011-10-03-08.51.00.000000,"087",09/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",6000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",0.00,"W"," ",0.000000,0.00,0.0000,0.00,0.0000,0.00,"F",28.500000,0.000000,0.0000,"Q",0.00,"Q",45,60,"Q","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","S","Y","N",100.00,0.00,"Y","N",100.00,"A",,,0.,0.,0.00,0.," ",0.00,0.0000,0,0,0,0.,0.,0.,0.00," ",10/01/2012,"AC","16","10","M","N","30","N","N",0.00," ",1,0,02/01/2011,01/31/2012,0.00,0.00," ",0,"N",2010,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"05","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,1800000.00,20.000000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1102101","90",02/01/2011,01/31/2012,"00000",2011-03-28-11.23.00.000000,"128",2011-04-04-10.04.00.000000,"128",03/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",6000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",0.00,"W"," ",0.000000,0.00,0.0000,0.00,0.0000,0.00,"F",28.500000,0.000000,0.0000,"Q",0.00,"Q",45,60,"Q","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","S","Y","N",100.00,0.00,"Y","N",100.00,"A",,,0.,0.,0.00,0.," ",0.00,0.0000,0,0,0,0.,0.,0.,0.00," ",10/01/2012,"AC","16","10","M","N","30","N","N",0.00," ",1,0,02/01/2011,01/31/2012,0.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"05","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,1800000.00,20.000000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1104101","90",04/01/2011,03/31/2012,"00000",2011-04-26-13.02.00.000000,"466",2011-04-27-14.08.00.000000,"466",04/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",30000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",110000000.00,"W"," ",0.000000,24933700.00,0.0000,0.00,0.0000,0.00,"F",27.000000,0.000000,0.0000,"Q",0.00,"Q",60,60,"Q","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","S","Y","N",90.00,0.00,"Y","N",90.00,"A",,,0.,0.,24933700.00,0.," ",500000.00,0.0000,0,0,0,0.,0.,0.,0.00," ",09/01/2012,"AC","24","10","O","N","30","N","N",0.00," ",1,0,,,0.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"10","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,6800100.00,22.667000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
"1104102","90",04/11/2011,03/31/2012,"00000",2011-04-26-14.52.00.000000,"466",2011-04-26-14.52.00.000000,"466",04/01/2011," ",,,0.00,"N",0.00,"90",100.000000," ",32000000.00,0.00,0.00,0.00,0,0," ",0.00,0.00," ","N",0.00,,"N",110000000.00,"W"," ",0.000000,13566300.00,0.0000,0.00,0.0000,0.00,"F",27.000000,0.000000,0.0000,"Q",0.00,"Q",60,60,"Q","N",0,0,"N","N"," ",0.00," "," "," ",0.00,"N"," "," "," ",0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.0,0.0,0.0,0.0,,,,"Y","S","Y","N",90.00,0.00,"Y","N",90.00,"A",,,0.,0.,13566300.00,0.," ",500000.00,0.0000,0,0,0,0.,0.,0.,0.00," ",,"AC","24","10","O","N","30","N","N",0.00," ",1,0,,,0.00,0.00," ",0,"N",2011,0.0000," ",0.0000,0.0000," ",0.0000,0.0000," ",0.0000," "," "," "," ",0.0000," ","00000 ","C",0.00,0.00,"10","N","N"," "," "," "," "," "," ",0.00,0.00,0.00,0.00,0.00,3946560.00,12.333000,0.000000,0.00,0.00,0.00,0.00,,"N","","",""
Re: Remove New line Char from Text file
I have checked in Notepad++ , special char is LF,
after running this script it removing the rows which has special char
after running this script it removing the rows which has special char
Re: Remove New line Char from Text file
Pasting it in the forum removes the characters. If you can upload it to some web file host then we can download it.
This works here:
Input file: "sample.csv"
output file: "newfile.csv"
This works here:
Input file: "sample.csv"
output file: "newfile.csv"
Code: Select all
@set @JScript=1/*
@echo off
setlocal
cscript //nologo //E:JScript "%~f0"
goto :eof
*/
// JScript
//
var ForReading= 1
var ForWriting = 2
var fso = new ActiveXObject("Scripting.FileSystemObject");
// var input = fso.OpenTextFile("c:\\temp\\webconfig.txt", ForReading)
// var output = fso.OpenTextFile("c:\\temp\\newWebConfig.xml", ForWriting, true)
var input = fso.OpenTextFile("sample.csv", ForReading)
var output = fso.OpenTextFile("newfile.csv", ForWriting, true)
var data = input.Readall()
data = data.replace(/\x0A/gi, "")
data = data.replace(/\x0D/gi, "\x0D\x0A")
output.Write(data)
input.Close()
output.Close()
Re: Remove New line Char from Text file
I edited the post above.
-
- Posts: 22
- Joined: 20 Nov 2012 12:42
Re: Remove New line Char from Text file
Hi.
I need more information, do you refeer to the new line created with the echo command with redirected output to a file? if yes....
echo|set /p=blablabla
echo|set /p=blablabla>blabla.txt
regards
I need more information, do you refeer to the new line created with the echo command with redirected output to a file? if yes....
echo|set /p=blablabla
echo|set /p=blablabla>blabla.txt
regards
Re: Remove New line Char from Text file
while running the script i am MD
C:\folder\sp.bat(18, 1) Microsoft JScript runtime error: Bad file name or number
Re: Remove New line Char from Text file
pls download the file from below link
https://www.dropbox.com/sh/qhrdegllkfpoj0p/E6Ix-5i__D
https://www.dropbox.com/sh/qhrdegllkfpoj0p/E6Ix-5i__D
Re: Remove New line Char from Text file
Rename the input file to sample.csv and it should work.
Re: Remove New line Char from Text file
I Have made changes in script and given, my file location and name.
Code: Select all
@set @JScript=1/*
@echo off
setlocal
cscript //nologo //E:JScript "%~f0"
goto :eof
*/
// JScript
//
var ForReading= 1
var ForWriting = 2
var fso = new ActiveXObject("Scripting.FileSystemObject");
// var input = fso.OpenTextFile("c:\\temp\\webconfig.txt", ForReading)
// var output = fso.OpenTextFile("c:\\temp\\newWebConfig.xml", ForWriting,
true)
var input = fso.OpenTextFile("Z:\STG_URS\1\115A_CONTRACT_EXPER",
ForReading)
var output = fso.OpenTextFile("Z:\STG_URS\1\newfile", ForWriting, true)
var data = input.Readall()
data = data.replace(/\x0A/gi, "")
data = data.replace(/\x0D/gi, "\x0D\x0A")
output.Write(data)
input.Close()
output.Close()