Options

using a dataport to import data from a textfile

jayshynejayshyne Member Posts: 29
what i was actually trying to do is import data from a textfile into a table using a dataport. what is happening is that when i run the dataport it just freezes. the status bar doesnt move at all. i even left it over an hour and i just came to meet it like it was before. I need URGENT HELP!!!!! ](*,)

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Hi,

    I think we need some more information about the dataport, to give help.

    Have you tried debugging the dataport?

    How big is the text file?

    Is it an empty table before the import?

    Do you do Autoinsert or a Manual insert?

    Wat are the DataItem separators?

    Are there any strange characters in the import file?

    Is there a header in the importfile? Have you tried skipping it?
  • Options
    kinekine Member Posts: 12,562
    Did you define the dataport fields???
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jayshynejayshyne Member Posts: 29
    Yes i tried debugging the dataport and size of the delimited text file is about 17MB big and
    this character  appears at the end of every record.there is no header in the import file.
    kine asked
    Did you define the dataport fields??
    where do i have to define the dataport fields?
    the fields in the table am trying to import are 14 and the table is empty before import.
    field separator is "," and i tried the dataport without field start and end delimiters but non of them worked out.
    dataitem separators are <<NewLine><NewLine>>

    i've also tried to write a codeunit to do the import by using the selectstr function but what happens is it writes to the nav. table for a while and throws an error. I've also managed to import the data into sql server so if possible i would like to know also how to import data from sql server to navision database.[/code]
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Probably the  character messes things up. :(

    I had this once to.

    Search this forum for info about reading from sql to Navision. Loads of info. :D
  • Options
    kinekine Member Posts: 12,562
    jayshyne wrote:
    kine asked
    Did you define the dataport fields??
    where do i have to define the dataport fields?
    [/code]

    If you are designing your dataport and click "View - Dataport Fields". Have you defined some "fields" there (there can be variables too)?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    GrantGrant Member Posts: 30
    With a file of this size, and the fact that the import file has "funny characters", using a dataport may not be feasible. I had a similar issue, with **very large** input file, and dataports were impossibly slow, like you are experiencing. I ended up using my own code to import and process the file. It took a lot more work to get this functioning, but unless you want to wait days for the import to process, the speed increase was worth the effort for me (not to mention the client).

    For example: I ended up using Navision FILE datatype. Here is some information to give you at least a head-start on this method. I suggest taking a very small sample file first, and get it working with that, before trying it on the full-size version.

    VARIABLES:
    FileID --> Variable with DataType = File
    BinaryLine --> DataType = Binary

    CODE:
    FileID.WRITEMODE(FALSE);
    FileID.TEXTMODE(FALSE); (lets you read non-ascii "funny" characters)
    FileID.OPEN(FileName);
    ...
    ...
    Bytes := FileID.READ(BinaryLine);
    ByteCount += Bytes;
    WHILE Bytes > 0 then
    BEGIN
    Do whatever you need to do here, depending on the nature of your data.
    What I did is to transfer, one character at a time, the data from the
    BinaryLine into a TextLine, as follows.
    TextLine[ImportStrCurrChar] := BinaryLine
    Of course, there is a bunch of other logic I had to include to compress
    spaces, ensure I don't overrun array boundaries, parse data properly,
    and so on.
    END;
Sign In or Register to comment.