Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] When is a line feed really a line feed?



On Sat, 04 Dec 2010 02:53 +0900, "Dave M G" <dave@example.com> wrote:
> So, is there a sure fire way I can set up my CSV file so that it is
> using \n for new lines? Like, rock solid sure so that either it works,
> or if it doesn't I can say confidently to the other guy that the
> problem might be his end?

Dave,

I'm no authority on this stuff, but I think that \n doesn't refer to an
actual character... I think it is an abstraction referring to whatever
is the line terminator used by the OS at hand (making the other guy's
statement somewhat tautological :-)

The actual characters are CR (ASCII 13) and LF (ASCII 10).  UNIX/Linux,
of course, uses LF as \n, Mac uses only CR, and DOS/Windows uses CRLF.

I use the following tidbit to see what actually exists as \n in a
text file:

  $ perl -ne 's/\015/<CR>/g; s/\012/<LF>/g; print "$_\n";'  <filename>

This converts CR and LF to visible form. You could use a similarly
simple program in Perl^H^H^H^Hyour favorite dynamic language to convert
the line terminators in your CSV file.

HTH,
Dave


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links