CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 1999
    Location
    MA
    Posts
    4

    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]


  2. #2
    Join Date
    Jul 1999
    Posts
    111

    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



  3. #3
    Guest

    Re: Unix Ascii Text importing

    Copy the file one byte at time, as you find
    chr(10) write chr(13) followed by chr(10).



  4. #4
    Guest

    Re: Unix Ascii Text importing

    use something like this on the entire file:
    strString = Replace(strString, vbLf)


  5. #5
    Join Date
    Jul 1999
    Posts
    111

    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



  6. #6
    Guest

    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);
    }





  7. #7
    Join Date
    Jul 1999
    Posts
    111

    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



  8. #8
    Guest

    Re: Unix Ascii Text importing(the end)

    You've been nice



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured