Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OT - Need Guru help with Unix csv file - Please!

2 views
Skip to first unread message

Theo Pistorius

unread,
Nov 25, 2002, 2:36:52 PM11/25/02
to
Thanks a lot guys, I solved the problem - replaced the #10's with #13's
loaded it into a tRichmemo
Saved back to text.
it solved my problem. All sorted out now tks.
Theo
.

Paul Motyer [TPX]

unread,
Nov 25, 2002, 4:48:33 PM11/25/02
to
"Theo Pistorius" wrote

> Thanks a lot guys, I solved the problem - replaced the #10's with
#13's

Hi Theo,

You can load the file into MS Word - then use SaveAs (*.txt - plain
text) and Word will replace the unix line terminator with CRLF for
you - quick & dirty so I like it

--
Paul Motyer


Theo Pistorius

unread,
Nov 25, 2002, 1:01:14 PM11/25/02
to
Hi (my apologies but I'm deperate for a quick answer, and all the Gurus hang
around here)
I have a problem with a text file from a unix machine.
Normally I have no problems reading the text. This file however
has only one line broken with little blocks, (control characters)
visible if file opened with Notepad. It's almost as if it is rtf, opens ok
with wordpad.

HELP! - how to I get over this one please?

Is there a way i can "convert" it to be a normal comma delimited file?

I would normally read a comma/delimited file ok with this code
while not eof(f) do
begin
readln(f, s);
import.append;
x:=0;
while pos (',',s) <> 0 do
begin
import.fields[x].asstring:=copy (s,1,pos(',',s)-1);
s:= copy (s, pos(',',s)+1,length(s)-pos(',',s));
x:=x+1;
end;
import.fields[x].asstring:=s;
end;
import.post;
CloseFile(f);

Your help will be highly appreciated, thank you
Theo

Sean Winstead [TurboPower]

unread,
Nov 25, 2002, 1:19:03 PM11/25/02
to

>Hi (my apologies but I'm deperate for a quick answer, and all the Gurus hang
>around here)
>I have a problem with a text file from a unix machine.
>Normally I have no problems reading the text. This file however
>has only one line broken with little blocks, (control characters)
>visible if file opened with Notepad. It's almost as if it is rtf, opens ok
>with wordpad.
> ...

Unix uses a different line terminator than Windows. Where Windows
uses CRLF for a line terminator, Unix uses CR. Or it might be LF. I
forget which but it definitely uses only one of them.

Maybe there's a utility you could use to preprocess the file and turn
CR into CRLF. Or you could change your code that reads the file by
reading byte by byte until you encounter the line terminator.


Franz-Leo Chomse [TPX]

unread,
Nov 25, 2002, 2:09:37 PM11/25/02
to
On Mon, 25 Nov 2002 20:01:14 +0200, "Theo Pistorius" <th...@powertill.com> wrote:

>Hi (my apologies but I'm deperate for a quick answer, and all the Gurus hang
>around here)
>I have a problem with a text file from a unix machine.
>Normally I have no problems reading the text. This file however
>has only one line broken with little blocks, (control characters)
>visible if file opened with Notepad. It's almost as if it is rtf, opens ok
>with wordpad.
>
>HELP! - how to I get over this one please?

Unix convention is to only have a LF as line separator, whereas
DOS and thus Windows uses a CR + LF pair. The old readln needs
this cr lf pair.

There is a pair of utilities unix2dos and dos2unix which switches
between these conventions. So you should get yourself a copy
of cygwin, the most common windows implementation of the GNU
environment.

In the latest Delphi version there is a utility SetLineBReakStyle which allows
to adjust the convention used in a textfile.

Regards from Germany

Franz-Leo
Franz-Leo Chomse(mailto:Franz-Le...@tpx.turbopower.com)
FF Foundry at http://community.turbopower.com
Newsgroup search at http://www.tamaracka.com
Fixes and updates at ftp://ftp.turbopower.com/pub/flash/updates/

Franz-Leo Chomse [TPX]

unread,
Nov 25, 2002, 3:11:22 PM11/25/02
to

#13 alone is invalid, it can't be read with readln anymore after the LineBreak extension.

Curt

unread,
Nov 25, 2002, 5:36:22 PM11/25/02
to
Here's my favorite solution --

Open it with the console 'Edit' program, and save it. The line terminators
will now all be correct for Windows or DOS. The 'Edit' program can be found
in the [WINDIR]/Command directory.

Curt.


"Theo Pistorius" <th...@powertill.com> wrote in message
news:k4FAYyK...@tpsmail01.turbopower.net...

0 new messages