Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exporting numbers in text (csv) files with specified format

Status
Not open for further replies.

uscitizen

Technical User
Jan 17, 2003
672
US
hi,

i have numerical three fields in my table which need to be exported (via a query) into csv text file. they are height, weight and dosage amount. the first two must have one significant digit to the right of the decimal point. dosage, on the other hand, must have three significant digits to the right of the decimal point. in the eventuality the number exported has no decimal value, i.e. in the event it happens to be integer valued, then either a single zero or three zeroes must appear to the right of the decimal point in the case of the height/weight and dosage fields, respectively. leading zeroes would not be wanted.

i have tried my hand at fixing the display of the values in the column/field definition -- they display alright, but in the exported text file, all fields are being exported with two significant digits to the right of the decimal point?

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
In the query use:
F1:format(Height,"0.0")

F3:Format(Dosage,"0.000")
 
thanks, but we're only half right. did i neglect to say that my client's needs are that the exported text values not be encapsulated by quotations. what i'm seeing are values like "158.4", "23445.320" as two examples; what i'd need to export instead would be 158.4 and 23445.320 (i.e. no quotations).

“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
Hi

Yes we have seen the Format() problem before havave we not!

Have you tried setting the DecimalPlaces property in the table design view to an appropriate value other than auto

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken Reay's approach will work provided you choose the 'Save Formatted' option on the export.

 
have a look at this kb article, which may be interesting...

( "If you have a table that contains a Number field with more than two decimal places, and you export the table to a text file, the decimal places are truncated to two positions."

their "resolutions" involve exporting the numbers as text, which results in the quotations marks i have tried to avoid.



“The philosophy of the school room in one generation will be the philosophy of government in the next." --- Abraham Lincoln
 
It also includes the Save Formatted setting which I mentioned in my last post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top