Unix Ascii Text importing
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
[email protected]
Re: Unix Ascii Text importing
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
Re: Unix Ascii Text importing
Copy the file one byte at time, as you find
chr(10) write chr(13) followed by chr(10).
Re: Unix Ascii Text importing
use something like this on the entire file:
strString = Replace(strString, vbLf)
Re: Unix Ascii Text importing
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
Re: Unix Ascii Text importing
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);
}
Re: Unix Ascii Text importing
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
Re: Unix Ascii Text importing(the end)