using a dataport to import data from a textfile

jayshyne
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!!!!! ](*,)
0
Comments
-
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?0 -
-
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]0 -
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.0 -
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)?0 -
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;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions