Output to CSV

david.weeks
Member Posts: 96
Hello All
I am outputting data from Navision to a CSV file.
However, there is another product involved later down the chain and they want me to remove "" and all , from numbers. For example, I currently output 1,323.34 They want it 1323.34
I am using the following to write to my csv file etc.
LostOutstream.WRITETEXT(STRSUBSTNO('"%1",', LrecSalesInvoice.Amount));
I have tried using FORMAT but to no success.
Ideas?
How do we remove the , from these numbers?
Thanks
I am outputting data from Navision to a CSV file.
However, there is another product involved later down the chain and they want me to remove "" and all , from numbers. For example, I currently output 1,323.34 They want it 1323.34
I am using the following to write to my csv file etc.
LostOutstream.WRITETEXT(STRSUBSTNO('"%1",', LrecSalesInvoice.Amount));
I have tried using FORMAT but to no success.
Ideas?
How do we remove the , from these numbers?
Thanks
0
Comments
-
Whats about a DELSTR?0
-
You mean DELCHR. Like
LostOutstream.WRITETEXT(DELCHR(FORMAT(STRSUBSTNO('"%1",', LrecSalesInvoice.Amount))),'=',',');®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
Right, because of the variable position of the dot(s)/comma, the DELCHR function should be used...
Dec1 := 12345678;
Dec2 := 122.34;
Dec3 := 1222;
Message('D1:%1, D2:%2, D3:%3',DELCHR(FORMAT(Dec1),'=',','),
DELCHR(FORMAT(Dec2),'=',','),
DELCHR(FORMAT(Dec3),'=',','));0 -
Wouldn't this work (to remove the enclosing quotes and any commas within the Amount)?
LostOutstream.WRITETEXT(FORMAT(LrecSalesInvoice.Amount,0,2) + ',');
As a general rule, you can achieve most output formatting results via a careful understanding and use of the second and third [optional] parameters to the FORMAT function. Agreed, the documentation in C/SIDE on-line help is a little cryptic (and even contains a few small errors), but a little experimentation will go a long way.0 -
Hi David
You can use the FORMAT Command with Standard format 1 or 2.The Standard Formats
The following tables list the predefined formats for each data type:
Decimal Format Example
<Sign><Integer Thousand><Decimals> 0 -76,543.21
<Sign><Integer><Decimals> 1 -76543.21
<Sign><Integer><Decimals><1000Character,.> 2 -76543.21
<Integer Thousand><Decimals><Sign,1> 3 76,543.21-
<Integer><Decimals><Sign,1> 4 761543.21-LostOutstream.WRITETEXT(FORMAT(LrecSalesInvoice.Amount,0,1) + ',');
Answer the question and wait for the answer.0 -
The extract from help just cited contains what I believe is a small error.
The help implies that Decimal Standard format 2 is equivalent to using the string '<Sign><Integer><Decimals><1000Character,.>' as the third argument to the FORMAT function.
I believe, however, that the <1000Character,x> attribute is used to specify the character to be used to separate the thousands groups, and is only useful in a format string that has specified <Integer Thousand>. As I understand it, <Integer Thousand> means: "Break the integer portion up into groups of three, and separate the groups with the <1000Character,x> attribute (if specified), otherwise use the 'Digit Grouping Symbol' specified in the for the Locale selected in the Control Panel." Furthermore, on experimentation, the <1000Character,x> attribute seems to be ignored even if specified for Decimal formats.
For those who wish to try for themselves, here's a hint:MESSAGE('%1',FORMAT(1234.56,0,'<Sign><Integer Thousand><Decimals><1000Character,.><Comma,,>'));
The correct 'fully specified equivalent' for Decimal Standard Format 2 is '<Sign><Integer><Decimal><Comma,.>' where the <Comma,x> attribute specifies the character to use to separate the Integer and Decimal portions of the result.
The difference between Standard Format 1 and Standard Format 2 is that Standard Format 2 is guaranteed to use a period for the decimal point, whereas Standard Format 1 will use whatever 'Decimal Symbol' is specified by the current user in the Control Panel.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