[NTLUG:Discuss] How to write converted file format from vi?

Fred James fredjame at fredjame.cnc.net
Thu May 6 17:40:25 CDT 2010


Neil Aggarwal wrote:
> Hello:
>
> I received a CSV file from a data provider, but it has
> a lot of non-printing characters in it.  Here is what
> the first part of the file looks like when I do a head
> on it:
>
> --" 5 " , " 5 0 0 9 0 " , " R 1 0 0 0 0 0 " , " 5 9 1 0 - 0 4 - 0
>
> When I open the file in vi, it displays as normal text:
>
> "5","50090","R100000","5910-04-0
>
> The bottom of the vi window states this:
> "t.csv" [converted] 934393L, 181540523C
>
> So, vi did some kind of conversion on it.
>
> I want to write the converted version of the file
> out to a new file, so I tried
>
> :w /tmp/test2.txt
>
> but the new file still has the non-printing characters.
>
> Is there a way to tell vi to write the version of the file
> it converted?
>
> Thanks,	
> 	Neil
>   
Neil Aggarwal
My first thought is a question ... is the file in question from an MS 
environment?  If so the characters you speak of may be CR (MS uses CR 
and NL, while UNIX/Linux uses NL).  'Sed' can handle removing them, or 
if you 'google (verb) on ...
    linux vi converted
... you may find some of that to be interesting reading.  Hope that 
helps - let us know if you need more, or if I am off the mark
Regards
Fred James





More information about the Discuss mailing list