How To Read TAB Delimiter?

Elie
Member Posts: 30
I need to create a function to import data into the Purchase Journal. The file I'm importing is TAB delimited but the structure of the data is different for each line in the file, so I don't think I can create a regular Dataport but instead I need to write code to read each line and extract the data I need. My Question is how can I read the TAB delimiter to determine when each field has started and ended?
I have tried to use the ConverString function to convert TAB to pipe symbol "|" but that did not work right it inserted a lot of Pipes and not one pipe for each tab. here is what I used: dhbTextFile := CONVERTSTR(dhbTextFile,' ',' |');
Thanks
I have tried to use the ConverString function to convert TAB to pipe symbol "|" but that did not work right it inserted a lot of Pipes and not one pipe for each tab. here is what I used: dhbTextFile := CONVERTSTR(dhbTextFile,' ',' |');
Thanks
0
Comments
-
Is it a txt file? I may get solution for you just please let me know is it text with TAB delimiter between values or it is excel sheet?0
-
Yes it is a txt file.
Thanks0 -
You can still use a dataport. Create global text variables to import into. Set the AutoSave, AutoUpdate, etc properties to No. Manually fill in your records with the text variables, using EVALUATE when necessary, and insert them.0
-
Still you can use dataport, instead of messing with head and writing code.
Open excel sheet (empty) and import the data from the this txt file. Use excel function 'Get External Data' and the choose From Text.
Text Import Wizard will be prompted. Make sure you choose delimited option then click Next, here make sure that Tab option has been selected then click Next and Finish.
Your data will be imported in correct format in separate columns. Now save this excel sheet as csv file and the result will be comma delimited excel file and now you can use dataport to import the data.
Thanks0 -
Thanks Matttrax for your reply. I'll try that and let you know..
Thanks again..0 -
Please check my solution as well
Thanks.0 -
Thanks Imranx101 for your reply.
users are getting several files everyday so they do not want to go through opening them in excel then saving them and then importing them. the customer want to press a button and Navision should take care of the rest.
Thanks again Imranx101.0 -
I suppose I should add, if possible, use an XMLport as Dataports are no longer supported in NAV 2009 RTC.0
-
Elie wrote:The file I'm importing is TAB delimited but the structure of the data is different for each line in the fileElie wrote:users are getting several files everyday so they do not want to go through opening them in excel then saving them and then importing them. the customer want to press a button and Navision should take care of the rest.
Having a set structure, would be a big leap forward here. Perhaps where ever these files are coming from you can explain to them to use the same layout time after time.
PS..Without seeing your data file we can only point you in the right direction. I prefer Tab delimited over CSV for dataports myself.0 -
Savatage wrote:Having a set structure, would be a big leap forward here. Perhaps where ever these files are coming from you can explain to them to use the same layout time after time.
I assumed (bad of me) that there was some sort of flag on each line telling what type it was. If that is not the case then you should definitely get them to standardize this.0 -
There is a flag for each line example:
IH for Header
IS for Lines
and so on...
Thank you0 -
viewtopic.php?f=23&t=39402
My Question is how can I read the TAB delimiter to determine when each field has started and ended?
Do you know these properties of the dataport?
FieldStartDelimiter -> <None>
FieldEndDelimiter -> <None>
FieldSeparator -> <TAB>
RecordSeparator -> <NewLine>
If each line starts with either IS or IH then your on your way.
as Alex says in the post above import the data into text variable and using if and/or case statements
to map each imported field to the proper nav field. Don't to forget to validate where necessary.
There is also a chapter on dataports in the ADG on the product cd. If you get stuck let us know.
ps this forum is chock full of dataport posts. don't forget search is your friend.0 -
Thank you all for your help.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