Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to remove all, except , and .

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
DTL01","xxa74wxxa741zzz ","235","`069669847 ","4","`404222699 ,"1","^@","^@","03","02","2","00","20061113","07:25:41",46,"^@","00000.00115","00000.00115"," ","ENTITY


The above mess I get in a file, about 150 000 records long. I would like to convert it to a standard csv file, so stripping all "", white spaces, `'s, and converting the ^@ (ascii code 0) to plain 0.



I am a bit lost on how to approach this task - could anyone point me in the right direction?

Appreciate any input.

 
Oh, and all records are on one line, and always the same format.
 
Are you sure that ^@ is ascii code 0? Ascii code 0 is null.

For the rest, you can remove the ", `, and whitespace like this:

cat <some.file> | tr -d '["` ]' > <some.new.file>

be sure to replace <some.file> and <some.new.file> with appropriate file names.

<some.new.file> would then contain this:

DTL01,xxa74wxxa741zzz,235,069669847,4,404222699,1,^@,^@,03,02,2,00,20061113,07:25:41,46,^@,00000.00115,00000.00115,,ENTITY


I am not sure what character "^@" is - but I dont think its an ascii 0 - so havent done anything to/with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top