Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2008

    Question Unanswered: Delphi - Append/format A Csv


    My application creates a CSV file and enters table data into it. The problem is - when csv file is created by Delphi it will have all the columns format set to GENERAL. Because of this the leading 0's are discarded. To resolve this I amended the code so that I have a pre-created file with column formatting set. Then in the application I copy this file and open it by issuing Delphi file command - append(). The Delphi is opening file correctly but is not writing the data into the csv file opened in this way. While if I amend the file type to .txt it does write the data. Can anyone provide inputs to resolve this issue. Either

    1. How to set column formatting of a .csv file from delphi. [The application do write the data when file is created and opened with rewrite() command] OR

    2. How I can append to a .csv file which I am copying from a pre-created .csv having the formatting set.


  2. #2
    Join Date
    Mar 2007

    Leading zeros in .csv file

    It seems that your problem is MS-Excel which truncates the leading zeros when displaying your data.

    The solution is simple if it is acceptable to you:

    - Open the .csv file with MS-Excel and highlight the entire column that contains data where leading zeroes are missing. Click option Format and choose tab 'Number'. Then select the option 'Custom' from the list in 'Category:' box. Enter number of zeros in the text box under Type: overwriting whatever is seen in the box (for example type, '000000' overwriting 'General' if you want your code to have a length of 6 characters displayed in Excel column).

    Hope this will solve your problem.

    Gurdeep Kalsi.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts