If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Delphi - Append/format A Csv

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-21-08, 04:52
Jyoti Hassanandai Jyoti Hassanandai is offline
Registered User
 
Join Date: Aug 2008
Posts: 1
Question Delphi - Append/format A Csv

Hi,

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.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 03-05-09, 00:13
kalsig kalsig is offline
Registered User
 
Join Date: Mar 2007
Posts: 2
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On