Unix import of a DOS spreadsheet...
John Esak
john at valar.com
Sat Sep 4 12:30:53 PDT 2010
For some reason my earlier reply about this hasn't shown up... I must have
screwed up and put some other address on it. I'll touch it up and send it
again.
Anyway, it was exactly what Ken said (almost). Here it is. Following some of
Ken's note:
> -----Original Message-----
> From: filepro-list-=valar.com at lists.celestial.com
> Sent: Saturday, September 04, 2010 2:09 PM
> On 9/3/2010 8:45 PM, Mike Schwartz wrote:
> > filePro 5.0.15K7R4 running on SUSE Linux 2.6.31
[...]
I was trying to import a spreadsheet that has lines
> that terminate in
> > 0D 0A hex. The Unix import function was reading in all the
> characters until
> > it got to the last 0A on the line, so the 0D was ending up
> in the last field
> > and messing up the screen drawing.
[...]
> how else can I
> > designate the 0A/0D combination on a Unix import line?
[...]
> Under Windows, where end-of-line is CR+LF, filePro's "\n"
> represents CR+LF.
> However, on *nix, where end-of-line is LF, filePro's "\n"
> represents just
> LF. If you have a Windows-formatted text file on *nix, then
> you'll need to
> eliminate the extra character somehow. You could remove the
> CR from the
> last field with XLATE(field,chr("13"),"").
>
> --
> Kenneth Brody
This is the whole key to understanding using IMPORT with DOS text files
versus Unix text files.
We have always just suggested that people use one of the conversions dtox
(and xtod) or several others that are built into the O/S. ON other than SCO
they have different names. Recently, I posted JP's version of delcr and
addcr one script linked with two names that does the same thing, so you can
put it on any *nix to do the job.
Really, another easy way if you have to move the file to the Unix or to the
Windows (DOS) system, (i.e., can't get to it through a LAN) just use FTP
with the correct mode switched on. In this case for a text file, you would
enter
asc
A lot of FTP client's turn BINary mode on by default. The ASCII mode of FTP
will convert the file correctly for the destination file system. If you are
moving a DOS formatted text file to UNIX it keeps LF line endings, if you
are moving a file to a Windows system, it leaves CR/LF line endings.
Stripping or adding whatever is necessary. Then, filePro deals with the
file correctly when you use IMPORT because filePro knows what kind of system
on which it is being run.
I would say this is one of the top questions of all time on the mailing
list. It should probably be the first thing gone over in the HELP files for
IMPORT (and to some extent EXPORT). I say to some extent for EXPORT because
often you don't know what kind of file system on which your export will end
up. So in that case, I would default to Windows. Most people will likely be
using that platform to read or import the file. Best thing in all cases is
to ask, so you KNOW how to construct the file. Then, as a final possibly
spurious tip, you should always zip (compress) any text file you are sending
out via email. This will keep the MTA's and MUA's from screwing with it.
John Esak
More information about the Filepro-list
mailing list