Click to See Complete Forum and Search --> : Unix Ascii Text importing


Sean Gearin
November 4th, 1999, 12:04 PM
I am trying to import an ascii text files that is created on a Unix machine. I was wondering if anyone knows how to deal with these file types. The problem that I am having is with the Unix text file because it only end with a carriage return and not with a carriage return and Line Feed. I have tried searching for the carriage return in the file chr(13) but it will not find it.

If anyone has had luck dealing with this in the past any help would be appreciated.

Thanks in advance

Sean Gearin
sgearin@modicon.com

Roger C
November 4th, 1999, 04:00 PM
I just checked on a unix box sitting next to me and the lines end with Chr(10). Not a Chr(13) in sight! :-)

It is often possible to enable translation when transfering a file from UNIX. For example, ftp will usually do the translation for you.

I don't know the details, but it may be worth looking into.

Roger

November 5th, 1999, 06:46 AM
Copy the file one byte at time, as you find
chr(10) write chr(13) followed by chr(10).

November 5th, 1999, 06:57 PM
use something like this on the entire file:
strString = Replace(strString, vbLf)

Roger C
November 5th, 1999, 08:49 PM
Nah, Too slow on large files... I'd do it in C.

int c;
while (c = fgetc(in) != EOF) {
if (c = 0x0A)
fputc(0x0D, out);
fputc(c, out);
}

Will run 100 times faster than same in VB. :-)

Please don't throw anything harder than a wrotten tomato!

The Devils Advocate

November 6th, 1999, 02:08 AM
I didnt say write it in VB.
You should make the following changes:


int c;
while ((c = fgetc(in)) != EOF) {
if (c == 0x0A)
fputc(0x0D, out);
fputc(c, out);
}

Roger C
November 8th, 1999, 08:58 AM
Ah, you busted me... two mistakes! I was just making fun anyway, that's why I added the comment about tomatos... so don't take it too seriously...

Welp, I think I've taken us about as far off topic as good taste permits. I suggest we take any further discussion on C to private mail. :-)

Have a good day,
Roger

November 8th, 1999, 09:23 AM
You've been nice :)