XMLport - Import from CSV and COUNT

PurpleHaze
Member Posts: 42
Hi,
I am importing some records from .csv file with XMLport.
Now, I want to put progress bar so I would need to count records that I need to import.
Is there any way to count records even before processing all of them? And which trigger I should use?
Thank you very much for your answers!
Greetings
I am importing some records from .csv file with XMLport.
Now, I want to put progress bar so I would need to count records that I need to import.
Is there any way to count records even before processing all of them? And which trigger I should use?
Thank you very much for your answers!
Greetings
0
Answers
-
No idea about progress bar for XMLport at all?0
-
On before loading the file in the xml port count the nodes in the xml file or lines in the csv file.
Trigger OnPreXmlPort();
Filename = CurrXMLPort.FILENAME;
XMLDoc = type:DOMDocument
XNLNodeList = type: IXMLDOMNodeList
If we were importing Items from an XML File and our nested Node was 'Item' we can get the count something like this untested code.CREATE(XMLDoc); XMLDoc.load(CurrXMLPort.FILENAME); XMLNodeList := XMLDoc.selectNodes('//Item'); TotalRecNo := XMLNodeList.length;
EDIT:
Not a xml file so the above would not work, for CSV we need to do it different as length is not the number of lines!
There is no CurrFile like a dataport so you could do something like above and count the lines in the csv file, open the file loop and count the lines and close the file!
Variables:
MyFile = FILE
TempTextVariable = Text 1000
TotalRecNo = IntegerCLEAR(MyFile); MyFile.TEXTMODE := TRUE; MyFile.OPEN(CurrXMLPort.FILENAME); WHILE MyFile.POS <> MyFile.LEN DO BEGIN MyFile.READ(TempTextVariable); TotalRecNo := TotalRecNo + 1; END; MyFile.CLOSE;
Now you can add a progress bar as normal!
HTH
DavidAnalyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com1 -
Hi David,
This is awesome!!! =D> =D>
Thank you so much!!!!! :thumbsup: :thumbsup: :thumbsup:
I own you a beer!!! \:D/ \:D/
Cheers!0 -
On before loading the file in the xml port count the nodes in the xml file or lines in the csv file.
Trigger OnPreXmlPort();
Filename = CurrXMLPort.FILENAME;
XMLDoc = type:DOMDocument
XNLNodeList = type: IXMLDOMNodeList
If we were importing Items from an XML File and our nested Node was 'Item' we can get the count something like this untested code.CREATE(XMLDoc); XMLDoc.load(CurrXMLPort.FILENAME); XMLNodeList := XMLDoc.selectNodes('//Item'); TotalRecNo := XMLNodeList.length;
EDIT:
Not a xml file so the above would not work, for CSV we need to do it different as length is not the number of lines!
There is no CurrFile like a dataport so you could do something like above and count the lines in the csv file, open the file loop and count the lines and close the file!
Variables:
MyFile = FILE
TempTextVariable = Text 1000
TotalRecNo = IntegerCLEAR(MyFile); MyFile.TEXTMODE := TRUE; MyFile.OPEN(CurrXMLPort.FILENAME); WHILE MyFile.POS <> MyFile.LEN DO BEGIN MyFile.READ(TempTextVariable); TotalRecNo := TotalRecNo + 1; END; MyFile.CLOSE;
Now you can add a progress bar as normal!
HTH
David
Hi All,
Hope I can borrow this thread:)
I have written an XMLPort where I import data from text file (*.TXT), everything works fine if I open NAV client where NAV server and NAV client is installed (NST is running), but if I open the NAV client on a Terminal Server (where NST is not running), then I get an error:
Could not find a part of the path 'E:\TESTDATA\REWE-CSV0413.txt.txt'.
XMPort code is this:
error pops here:
ImportedCSVFile.OPEN(currXMLport.FILENAME);
Thank you
BR Damjan0 -
Hello @Damjan,
In this case you need first to download the file from the server and then process it.
You can use the codeunit 419 (File Management) to do that.
fileMgt.DownloadToFile(currXMLPort.FILENAME, clientFile);
ImportedCSVFile.OPEN(clientFile);
....
Regards.0 -
Hi,
I tried with @ftorenore suggestions, but it works on the NAV Server, but it does not work on terminal server where only NAV client is installed. I am working this on NAV2013 R2 version:)
Error pops:
Debugger stops here
0 -
I found out that it works as expected if I save file that has to be imported to the server where NAV Application Server is running
\\192.168.1.239\e$\TESTDATA
As file browser dialog opens, I have to select that exact location: \\192.168.1.239\e$\TESTDATA\file.txt
but, if I save the file to my desktop or on my local disk, and as file browser dialog opens and I select local location: C:\testdata\file.txt than error pops: File was not found.
I checked the user permissions and user has full permissions on folder where file is saved, and user is opening NAV client that runs under his user account, but NST user is not the same user as user who has opened the NAV client.0 -
Thanks that works as expected.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