Import file with tabs (without dataport)

ngebhardngebhard Member Posts: 127
Hello everybody,

any ideas if your importing a file with tabs without using a dataport?

We created a function to run several imports using a NAS timer setup. This works fine with field seperators like ";" or "|". Now we need to run the function with tab as field seperation. I tried to convert it to char but this doesn't work because the tab comes as several blanks. Any hints?

Thanks a lot!
Regards
Nicole
ProTAKT Projekte & Business Software AG
Microsoft Dynamics NAV Partner
Bad Nauheim, Germany
http://www.protakt.de
http://twitter.com/protakt

Answers

  • lubostlubost Member Posts: 623
    If you have blanks in input file - means that you have not separated fields with tabs. You can use DELCHR function if it is possible.
    If you want to maintain tabs separated file, you have to define char variable (length 1 byte), assign value 9 (TAB code) into it and separate needed field from imput string.
  • ngebhardngebhard Member Posts: 127
    The file has tabs as field seperator. But if I use the File.Read-function the tabulator (shown as hexcode 09) comes up as several blanks (shown as hexcode 20). I tried to use a char-variable but it doesn't match, because the File.Read-function turns them into blanks.

    Any ideas?!
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    Hi

    I think only via InStream. For example so:

    f.TEXTMODE := TRUE;
    f.OPEN('c:\1.txt');
    f.CREATEINSTREAM(stream);

    WHILE stream.READTEXT(str) > 0 DO BEGIN
    MESSAGE(str);
    FOR i := 1 TO STRLEN(str) DO
    IF str = 9 THEN
    str := '^';
    MESSAGE(str);
    END;

    f.CLOSE;
  • ngebhardngebhard Member Posts: 127
    I used the instream-method and it worked! Thanks a lot!!!

    Regards
    Nicole
    ProTAKT Projekte & Business Software AG
    Microsoft Dynamics NAV Partner
    Bad Nauheim, Germany
    http://www.protakt.de
    http://twitter.com/protakt
Sign In or Register to comment.