Retain Leading Zero in CSV

Hi,
We are exporting the output in CSV format but CSV is not showing leading zeros.
For example -  if the value is 0002 then it appears as 2 in CSV.
Is there any method or trick to retain leading zeros.
Although, this can be done through excel macro(after the file is opened) but for that manual intervention is required.
Is there any way to run excel macro through web page ? I mean if we could automate the procedure of running macro.
so that user just clicks on the button "Export to CSV" on web page and he gets the output in Excel with leading zeros retained.
Regards,
Anil

Hi Jeremy,
Although i am building a string in BLS and writing it into a csv file
but I tried to test your statement by simulating with test data
For one column of "VARCHAR2" datatype, the value is '0002'
when i test the query results with text/xml output, the SQLDataType="12"
and the value is 0002
but when i test the query results with text/csv output, the value is 2.
Regards,
Anil

Similar Messages

  • Leading zeros in CSV file.

    Hi Team,
    I need to retain leading zeros in CSV file.
    I could eliminate this problem in XLS file by using this tag in the RTF Template:
    <fo:bidi-override direction="ltr" unicode-bidi="bidi-override"><?XML_ELEMENT?></fo:bidi-override>.
    So, when i do an Export from Publisher for excel document its gives me correct values. i.e zeros are retained.
    But when i select "CSV" and then hit Export , it gets saved in txt file and the txt file has the zeros.
    but when i rename it to ".csv" and open it does not retain zeros.
    Can you please let us know how can we achieve this.
    Thanks for help!
    Bhupendra Gupta

    Hi Bhupendra,
    If its a number the leading zeros will be eliminated in CS in the default CSV .can't do much on this.
    But if use the delimiter e-text and get the output file, you can get the leading zeros as needed..
    Follow this
    http://winrichman.blogspot.com/2009/09/delimiter-based-e-text.html
    http://winrichman.blogspot.com/search/label/BIP%20E-text

  • Retaining leading zero after sum operation

    I have a variable g = 00000005. Now when I am adding g = g + 1.
    The result is coming 6 but without leading zeroes.How could I retain leading zero after sum operation.

    Hi Priya,
    Declare the g as type N.. then do sum.. okay..
    ex :
    data : d(7) type n value '0000005'.
      g = g + 1.
    write : g.
    output is : 0000006.
    Raghunath.S

  • Leading Zero in CSV File

    Hello,
    I have a report which shows the customer details and the report is working fine, but when I download this report to CSV format the leading zeros doesn't show up on the Customer_ID.
    How do I fix this? Please Advice..Thank you.
    - Abhi.

    The problem is with Excel reading the CSV file. It considers fields with leading zeros to be numeric, not string, and thus removes the leading zeros.
    One of the simpler cheats is to put a single quote in front of the leading zeros. The leading zeros remain, but so does the single quote until the user goes into each cell and hits the [Enter] key.
    Another option is to push the data into an excel spreadsheet right in PeopleSoft and deliver it to the user (binary operation, not CSV). Look at the query viewer for examples on how this is done with existing query results.

  • Preserve leading zeros in CSV file.

    Hello...
    I am creating a file on the fly and attaching with email.
    emp_no starts with 0001,0002,0003 ...etc.
    When file write emp_no to csv file...i looses leading
    zeros...what is best solution to preserve zeros?.
    In excel file creation, i am using
    style="mso-number-format:0000;" to preserve leading zeros.
    But by using cffile, i am not able to use style.....Is there
    any other way to preserve leading zeros?
    <cffile action="write" file="#dirname#/emp_mon.csv"
    output="List of Employees" addnewline="Yes">
    <cfoutput query="emp_q">
    <cffile action="append" file="#dirname#/#filename#"
    output="#emp_no#,#e_name#,#e_address#,#sal#" addnewline="Yes">
    </cfoutput>

    I'd suspect your CSV is fine, ie. if you open it in WordPad
    or NotePad you will see 0002. The problem is with whatever you're
    importing it into. Excel? If something else I don't know. If Excel,
    your Import spec, saved or on-the-fly needs to say Text on that
    field rather than the default General which simply means make a
    number (zero-suppressed) whenever possible. Single or Double quotes
    (on each field that needs it) are a workaround provided you specify
    them as "Text Qualifier", but you don't seem to want to do that, so
    Text is the only other method.

  • Exporting Numbers file with leading zeros as csv file

    When I export a list of mobile phone numbers with leading zeros (086* etc.) from Numbers as a csv file, the leading zeros are stripped out, although the cells are previously formatted as text. What can I do about this?

    "When I export a list of mobile phone numbers with leading zeros (086* etc.) from Numbers as a csv file, the leading zeros are stripped out, although the cells are previously formatted as text. What can I do about this?"
    Well, the first thing you could do would be to post your question in one of the forums for Numbers.
    Click Discussions to get to the Discussions index page, then the section for the version of iWork you're using, then the Numbers forum in that section.
    In AppleWorks (which doesn't offer an opportunity to Save as or Export as csv) I'd force the application to see the phone numbers as text by inserting some non-numeric characters into the string of digits.
    Examples: 000-123-4567, 000 123 4567
    It may also be a function of the application you are using to open the csv file.
    When I did a brief test of the suggestion above with Numbers '09, I got this result on opening the file in Text Edit:
    ,1234567890,num
    ,123-456-7890,tex
    ,0123456789,num
    ,012-345-6789,tex
    ,0001234567,num
    ,000-123-4567,tex
    Note that both the examples entered as a string of digits only (num) and those entered with inserted hyphens (tex) kept the leading zeroes. Cell format for the column containing the phone numbers was set to Text.
    Regards,
    Barry

  • To retain Leading zeros

    Hi,
    I have  a table control .In which for a field (char or numc) the leading zeros are not retained. Pls help what should be done to retain the same.
    Thanks in advance
    Ram

    Hi Prabha,
    See this code,
    data : a(8) type n.
    a = '2345'.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input         = a
    IMPORTING
       OUTPUT        =  a  .
    write :/ a.
    The output will be 00002345.
    This function module places zeros if the input variable length is greater than occupied. Here a is having 8 char length and have only 4 chars so the first 4 spaces gets filled with zeros.
    Hope u got it.

  • How to retain leading zeros in module pool screen

    Hi experts,
    I have a ztable field of type NUMC4 being displayed on a module pool screen, the value in the field is '0001', but on the screen it displays value as '1' (without leading zeros), When I save the record, Even in the databse it stores as '1'.
    But I have checked in debugging the field always contains '0001' in the program execution and I have also used 'CONVERSION_EXIT_ALPHA_INPUT' in the PBO but no use.
    Pls suggest.
    Thanks,
    Deepak

    Check the screen attributes for the field. There is an option to show leading zeroes.
    edit.
    And how did you see it was stored a 1 and not 0001? Using SE16N? Mind you: with SE16N conversion-exits are executed automatically thus showing 0001 as 1.
    To make sure: double click on the record in SE16N and look if it's still 1 and not 0001.

  • How to retain leading zeros in an excel sheet

    Hi,
    In my application I need to export the response from a struts action class to an excel sheet. I have done the coding but while exporting to the excel , the leading zeros are getting truncated. If the value is '01' it is displayed as '1' only.
                    response.setContentType("application/text");
                             response.setHeader("Content-disposition",
                                       "Attachment;filename=\"export.xls\"");
                             response.getOutputStream().println(data);
                             response.getOutputStream().flush();This is the code which I am using to export all the data to the excel.Here the variable data is a String .
    Kindly help on this issue.
    Thanks in advance...
    Edited by: 2569 on Jan 10, 2008 8:59 PM
    Edited by: 2569 on Jan 10, 2008 9:51 PM

    2569 wrote:
    I tried that way also, but its not working. I have defined all the values as strings only. Thanks for ur replyWhich API are you using to write excel files? You can try to surround the numeric string value with singlequotes (or escaped doublequotes)String numericString = "'01'";so that Excel interprets it as string.

  • Retain Leading Zeroes

    Hi,
    I have a column value 0008-1913 in text file. When i dump this into a database in SQL server, the value becomes Aug-13.
    I am dumping from a text file to SQL using a query transformation. No script or function involved, just mapping the output schema with the input schema.
    How can i retain the same value in SQL?
    Appreciate your help.
    Arun

    Problem rectified.
    Arun

  • How to keep leading Zeros in a CSV file

    Hi All -
    I am trying to keep leading zeros in CSV file. Ex. I need 00001 but not just 1. I tried formatting the cells but not getting saved. Any advise please.
    Thanks.

    Dear Super Man  ,
    Try using ALPHA Conversion Routine
    ALPHA Conversion Routine
    The ALPHA conversion is used in the BW system for each presetting for character characteristics. The ALPHA conversion routine is registered automatically when a characteristic is created. If you do not want to use this routine, you have to remove it manually.
    The ALPHA conversion routine is used, for example, with account numbers or document numbers
    For more details
    http://help.sap.com/saphelp_nw04/helpdata/en/9b/f9c18f5a07f0459127e9676ae22a54/frameset.htm
    Hope it helps
    Regards
    Bala

  • Preserve Leading Zeros in SQL export to TXT

    I need to export accounting data from SQL to a series of TXT files, with a "ServiceCode" of 02. I cannot get the
    leading zero to stick.
    Here is the section of the SQL stored procedure that pulls the serviceCode of “02.”
    IF @serviceCode =
    '02'
    BEGIN
    SELECT @total =
    COALESCE(SUM(Price),0),
    @itemCount = COALESCE(SUM(ItemCount),0)
    FROM #tblData
    WHERE CostCenter = @costCenter
    AND ServiceCode
    IN(SELECT
    DISTINCT [ServiceCode]
    FROM [DsPcDb].[dbo].[Service_T]
    WHERE [Name]
    NOT
    LIKE
    '%color%'
    AND [Name]
    NOT
    LIKE
    '%scan%'
    AND [Name]
    NOT
    LIKE
    '%fax%'
    AND [ServiceCode] <=
    196623)
    END
    ...and here is some text from the "02" output .txt file, with the leading zero stripped out of the third column:
    11/21/2014,00000-24057,2,1125
    11/21/2014,00001-MKTG12,2,150
    11/21/2014,40059-00395,2,62
    11/21/2014,40059-00409,2,32
    11/21/2014,40059-00428,2,12
    11/21/2014,40059-00432,2,2
    11/21/2014,40059-00434,2,218
    This won't let the receiving database import the data. ("02" is a specific code.) Three other txt files from this
    procedure are imported properly.
    Please help! Thanks!

    You need to cast the servicecode field to varchar to make sure it retains leading zero.
    So in your case make variable type varchar and also places where you select from field cast it to varchar.
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Excel - CSV leading zeros

    Hi
    I get sent an Excel workbook from a client that I need to save as a CSV file so that I can then use the CSV file with another piece of software. When I save the workbook as a CSV file, then when I open it again, the cells in column A don't retain the
    leading zero. In the workbook, the data in column A is entered as '012345.
    Any ideas?
    Viv
    Viv Haig

    Hi,
    Any update?
    Regards,
    Melon Chen
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Leading zeros are dropped when exporting as csv

    I have a report that when I export as csv, leading zeros in text columns are dropped in excel. The text columns appear fine in the report, however, when I export the leading zero is gone in excel. For example, in the report my text column could have a value of 0101, when it is exported to excel it has a value of 101. The code behind the link to export to csv is f?p=&APP_ID.:&APP_PAGE_ID.:&SESSION.:FLOW_EXCEL_OUTPUT_R#REGION_ID#
    Is there a way to keep the leading zero in excel?
    Regards
    Mark

    Thanks for your reply. In my query I wrapped the column with double quotes as you suggest, and added the same column for display:
    select '"'||column1||'"' execl_col, column1 disp_col from table where ....
    Using htmldb_application.g_excel_format as a conditional display I can control what is displayed on the screen and export to csv the double quoted text field. I have that part working fine. Using my previous data example, I am now seeing in excel 0101"".
    Did I wrap the field incorrectly with double quotes? How can I exclude the
    double quotes in the export to csv?
    Regards
    Mark

  • Leading zero getting truncated in .CSV format GUI_DOWNLOAD

    Hello experts,
    I am trying to download the data using GUI_DOWNLOAD in .CSV format but the leading zeros are getting truncated. For instance Company code 0001 is displayed as 1 in the CSV File. But when I open the same file in notepad I am seeing 0001. Is this a known issue or this is how .CSV format should be?
    I have gone through some threads in SDN but they are not helpful.
    Your expert advise is much appreaciated.
    Thanks
    Abdul Hakim

    That is how excel displays values like 0001. It interprets them as a number and removes leading zeros.
    If you don't want this happen and you want excel to treat them like text, you need to append a quote at the beginning of the token like '0001
    You can use concatenate like below to append a single leading quote
    field = '0001'.
    CONCATENATE ''''  field INTO field.

Maybe you are looking for

  • Multiple problems with itunes and ipod touch

    I don't even know where to begin explaining all the problems I've had with itunes and my ipod touch, along with the troubleshooting that I've done to no avail.  Now, I'm totally frustrated.  So, here I am hoping that I can get some help from someone.

  • When I connect to my usual VPN connection, I can no longer connect to email, internet, etc.

    Upgraded to Yosemite.  When I connect to my usual VPN connection, I can no longer connect to email, internet, etc.  Only happening on my MacBook Pro.  My iMac works fine.  Thoughts?

  • Why am I getting an error message trying to view pdf files.

    When trying to open any pdf file, I have just started getting this message" The Adobe Acrobat/Reader that is running can not be used to view PDF files in a Web Browser. Please exit Adobe Acrobat/Reader and exit your Web Browser and try again. Why. I

  • When to add message type to distribution model

    hi i am bit confused on when to add a custom/std message type to distribution model. what are the conditions. is that always necessary to add the message type to distribution model. thanks

  • Time Machine Permissions Changed Problem

    Greetings- I'm experiencing problems restoring to built-from-scratch Lion OS installation on a new disk.  Before starting the process I ensured everything was backed-up everything using Time Machine, which was backing-up regularly, then did a fresh i