Importing a txt file

raven44
Member Posts: 85
Hi,
I have a a txt file that I wish to bring into some customized tables into Navision.
Is there a way to read through the file line by line and then populate the appropriate tables? As the file is formatted into sections, which need modification before importation into Navision.
Eg.
** Transaction ID 16367864 Date - 2006-12-01 01:40:00
** Base[9835]:Region 15 [Processing Department] Financial
- USER1 placed in section 1 with $50.00
- USER2 placed in section 2 with $150.00
- USER3 placed in section 3 with $135.00 [Initiated]
USER1 pays small fee - $5.00
USER2 pays big fee - $10.00
USER3 - no fee
End of transaction 16367864
** Transaction ID 16367852 Date - 2006-12-01 01:32:12
** Base[9835]:Region 15 [Processing Department] Financial
...and continues with a similar format.
With the example above, it would be transferred into 3 Navision tables.
I'm hoping that I will be able to use a Dataport. Is this possible?
Any ideas would be greatly appreciated.
Thanks in Advance.
I have a a txt file that I wish to bring into some customized tables into Navision.
Is there a way to read through the file line by line and then populate the appropriate tables? As the file is formatted into sections, which need modification before importation into Navision.
Eg.
** Transaction ID 16367864 Date - 2006-12-01 01:40:00
** Base[9835]:Region 15 [Processing Department] Financial
- USER1 placed in section 1 with $50.00
- USER2 placed in section 2 with $150.00
- USER3 placed in section 3 with $135.00 [Initiated]
USER1 pays small fee - $5.00
USER2 pays big fee - $10.00
USER3 - no fee
End of transaction 16367864
** Transaction ID 16367852 Date - 2006-12-01 01:32:12
** Base[9835]:Region 15 [Processing Department] Financial
...and continues with a similar format.
With the example above, it would be transferred into 3 Navision tables.
I'm hoping that I will be able to use a Dataport. Is this possible?
Any ideas would be greatly appreciated.
Thanks in Advance.
0
Answers
-
Just an idea.... :-k
It seems that your problem would be much simpler if you had an xml file (or if you could create an xml file from your txt) for the kind of information that you want to insert.
In that case I believe that the dataport would be much more easier to create...Always Look On The Bright Side Of Life...0 -
You can also create a codeunit to import your textfile line-by-line.
Something like:filRead.WRITEMODE(FALSE); filRead.TEXTMODE(TRUE); filRead.OPEN('The File'); intLen := filRead.LEN; WHILE filRead.POS < intLen DO BEGIN filRead.READ(txtOneLine); ... do something with the line ... END; filRead.CLOSE
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks, thats exactly what I'm looking for.
Sometimes it seems so simple.
Just an additional note for users that may go this route.
When pushing the txtOneLine into a table that has a different datatype, use EVALUATE.
An example can be found at:
http://www.mibuso.com/forum/viewtopic.p ... xt+integer
Thanks to all.0 -
Thank you for the code. I was able to import txt from an email. Here is the code
filRead.WRITEMODE(FALSE);
filRead.TEXTMODE(TRUE);
filRead.OPEN('C:\test.txt'); \\ File Location
intLen := filRead.LEN;
WHILE filRead.POS < intLen DO BEGIN
filRead.READ(txtOneLine);
FieldExist := STRPOS(txtOneLine,'Invoice'); \\ String to search
IF (FieldExist > 0) THEN
InvoiceTxt := COPYSTR(txtOneLine,FieldExist+10,9);
END;
filRead.CLOSE0 -
Unbelievable!
It's been a while since I opened and read a text file in C/Side - long enough that I can't remember exactly what to do.
So, off into ADG and C/Side Developers Help.
@#$%^&*+_)*&^%$#$%^&*)_!!!
Everything is there EXCEPT how to specify the file name. I keep going back to the page on File.OPEN thinking it's just GOT TO BE THERE ... but this is the syntax they show:
[Ok := ] File.OPEN
:-k
Thank <whomever> for Mibuso though - in about 90 seconds I find this thread and see:
filRead.OPEN('C:\test.txt'); \\ File Location
Well DUH - There's a secret parameter to the open command! \:D/
Sometimes ....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