How as change a file csv?

hugoisti
Member Posts: 26
Hello experts, I am creating a file from sql with a SP, once created this file I have to add a row to the file.
Was reading and I add the line, the problem is that no moves the lines that were already, the writes on.
The code that use is the following
IF EXISTS(Path + 'Compel_stg.csv') THEN
BEGIN
g_fileCompel.TEXTMODE := TRUE;
g_fileCompel.WRITEMODE := TRUE;
IF (g_fileCompel.OPEN(Path + 'Compel_stg.csv')) THEN
BEGIN
g_fileCompel.CREATEOUTSTREAM(oStream);
oStream.WRITETEXT('Date,SalesCode,SalesTeam,RevenueCategory,RevenueType,Amount,');
oStream.WRITETEXT('order_date,order_no,invoice_no,year,quarter,month,salesrep,ori_salesteam,');
oStream.WRITETEXT('region,enduser_name,enduser_state,enduser_zipcode,area_code,item_code,item_desc,number_of_users,');
oStream.WRITETEXT('product_code,order_type_code,sales_type_code,reseller_name,dist_name,account_id,channel_type,');
oStream.WRITETEXT('order_source,gl_account_no,product_group_code,license_start_date,license_end_date,prod_start_date,');
oStream.WRITETEXT('prod_end_date,TransCode');
oStream.WRITETEXT();
g_fileCompel.CLOSE();
already proven of everything and is not that passes, someone known as I can fix this, since thanks
best regards.
Hugo
Was reading and I add the line, the problem is that no moves the lines that were already, the writes on.
The code that use is the following
IF EXISTS(Path + 'Compel_stg.csv') THEN
BEGIN
g_fileCompel.TEXTMODE := TRUE;
g_fileCompel.WRITEMODE := TRUE;
IF (g_fileCompel.OPEN(Path + 'Compel_stg.csv')) THEN
BEGIN
g_fileCompel.CREATEOUTSTREAM(oStream);
oStream.WRITETEXT('Date,SalesCode,SalesTeam,RevenueCategory,RevenueType,Amount,');
oStream.WRITETEXT('order_date,order_no,invoice_no,year,quarter,month,salesrep,ori_salesteam,');
oStream.WRITETEXT('region,enduser_name,enduser_state,enduser_zipcode,area_code,item_code,item_desc,number_of_users,');
oStream.WRITETEXT('product_code,order_type_code,sales_type_code,reseller_name,dist_name,account_id,channel_type,');
oStream.WRITETEXT('order_source,gl_account_no,product_group_code,license_start_date,license_end_date,prod_start_date,');
oStream.WRITETEXT('prod_end_date,TransCode');
oStream.WRITETEXT();
g_fileCompel.CLOSE();
already proven of everything and is not that passes, someone known as I can fix this, since thanks
best regards.
Hugo
0
Comments
-
-
thanks, but is not the result that I need, I have to insert the line above the because it is the header of Report
some other idea?
best regard0 -
How about creating a 2nd file, writing the headers and then copying to it the contents of the 1st file?0
-
just to be clear - you want to create a datafile & THEN add the column Headers??0
-
Exact, I have a SP that generates a file, then I must add the headers to columns that contains the file.
In regard to the function to copy, exist? I do not know any,
read in Navision and not find any you copy files. the other that remains is to generate a new file add the headers and then read from a file I have insert in the other. but it is not very efficient.0 -
This code might be a little crude but I do believe it will help you find a solution...
Name DataType Subtype Length TmpBlob Record TempBlob (Temporary := YES!; Dimensions := 2) fPath Text 1024 oStream OutStream iStream InStream
fPath := 'C:\Documents And Settings\jwalker\Desktop\myfile.csv'; TmpBlob[1].Blob.IMPORT(fPath); TmpBlob[1].Blob.CREATEINSTREAM(iStream); TmpBlob[2].Blob.CREATEOUTSTREAM(oStream); oStream.WRITETEXT('Date,SalesCode,SalesTeam,RevenueCategory,RevenueType,Amount,'); oStream.WRITETEXT('order_date,order_no,invoice_no,year,quarter,month,salesrep,ori_salesteam,'); oStream.WRITETEXT('region,enduser_name,enduser_state,enduser_zipcode,area_code,item_code,item_desc,number_of_users,'); oStream.WRITETEXT('product_code,order_type_code,sales_type_code,reseller_name,dist_name,account_id,channel_type,'); oStream.WRITETEXT('order_source,gl_account_no,product_group_code,license_start_date,license_end_date,prod_start_date,'); oStream.WRITETEXT('prod_end_date,TransCode'); oStream.WRITETEXT(); COPYSTREAM(oStream,iStream); TmpBlob[2].Blob.EXPORT(fPath);
Cheers!0 -
Fantastic!!!, walked very well, many many thanks!!!
Best Regards0 -
You are most welcome0
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