Best way to remove the Header from a CSV file.

David_Singleton
Member Posts: 5,479
Just wondering what you guys prefer to do this.
I have "pseudo" csv file, that has the column names as headers. Currently I have a working dataport if I remove the headers manually. So I don't really want to rewrite the whole thing in code.
Option 1/ and the most obvious solution is just to have the user manually delete the header, the problem is that the file has a .CSV extension, so at some stage they are going to double click it, open it in excel, delete the first row, save it (some how) and then ruin the file. So option one out.
The other four options are
2/ My preferred option would be to convert the file to XML and be done with this horrid antiquated CSV nonsense.
3/ Hack the Dataport with an additional dataitem, and change the <<NewLine><NewLine>> itme seperator to something that is constant at the end of the header line.
4/ Read the file in CAL and rewrite back without the header.
5/ Call an external script to do it.
So out of curiosity what do most people prefer.
I have "pseudo" csv file, that has the column names as headers. Currently I have a working dataport if I remove the headers manually. So I don't really want to rewrite the whole thing in code.
Option 1/ and the most obvious solution is just to have the user manually delete the header, the problem is that the file has a .CSV extension, so at some stage they are going to double click it, open it in excel, delete the first row, save it (some how) and then ruin the file. So option one out.
The other four options are
2/ My preferred option would be to convert the file to XML and be done with this horrid antiquated CSV nonsense.
3/ Hack the Dataport with an additional dataitem, and change the <<NewLine><NewLine>> itme seperator to something that is constant at the end of the header line.
4/ Read the file in CAL and rewrite back without the header.
5/ Call an external script to do it.
So out of curiosity what do most people prefer.
David Singleton
0
Comments
-
For CSV files with headers - I use the Kriki's old skip headers.
viewtopic.php?f=5&t=105640 -
i like this one:kriki wrote:0
-
That's two votes for the Header Skip!
0 -
and rightly so, I would say0
-
Easier... if you are sure, that the first line is not longer than 1024 bytes...
----OnPreDataport var Line: Text1024; if CurrDataport.IMPORT then begin CurrFile.TEXTMODE := true; CurrFile.READ(Line); CurrFile.TEXTMODE := false; end;
0 -
Savatage wrote:
That's two votes for the Header Skip!
I will give it the third vote.
Done and working...David Singleton0
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