Skip to main content
13-Aquamarine
Aug 25, 2025 11:37 PM UTC
Solved

Write a comma delimited Text file

Hello,

 

I have to process~750 rows, pulling values from another PRIME file using the INCLUDE statement.  I'm trying to write a text file in a certain format (just 6 row sample).  First column of values would have no quotation marks.  Second column of values would be text or string if a decimal place was included, only to two decimal places.  The delimiter between rows would be a comma.  

Attached are a sample PRIME file of what I created and a text file of which I would like to see.

Ideas?

13-Aquamarine
Aug 26, 2025 2:37 AM UTC

Thank You.  You have it right.  2000 and 600 are just that.  No decimal places. 

But if a decimal, then need two digits, two decimal places to the right.  If it rounds up to a single digit, that's fine too.

10 replies

13-Aquamarine
Aug 25, 2025 11:38 PM UTC

Delimiter between columns would be a comma.

Translate
Werner_E
25-Diamond I
Aug 26, 2025 12:09 AM UTC

You want to see 600 without any decimal places but 2000.0 with one decimal place  and other numbers with two decimals?

Whats the difference between 600 and 2000? (and don''t say -1400 now 🙂 )

Translate
Werner_E
25-Diamond I
Aug 26, 2025 12:37 AM UTC

See if the attached custom WRITE function is of use for your. It does what you demand except that it shows "2000" and not "2000.0" and it does not show the trailing zero in "17.80" but rather just "17.8".

If showing the traling zero is mandatory it could be done with some work.

If showing the decimal 0 in 2000.0 is mandatory you would have to explain why there should be one decimal in the representation of 2000 but none when 600 is shown.

 

Note that my function has no error checking built-in. It assumes that the Matrix has two columns, the first column must be strings throughout and are written without the quotes. The second column should consist of either numbers or strings only (no NaN, no vector or matrix, ...) and are written in quotes, numbers are rounded to 2 decimals and are written without showing trailing zeros.

And if you provide an empty string "" a zero byte would be written which, depending which text reader you use probably will look like a space.

 

Prime 11 sheet attached

Translate
Snowshoeman13-AquamarineAuthorAnswer
13-Aquamarine
Aug 26, 2025 2:37 AM UTC

Thank You.  You have it right.  2000 and 600 are just that.  No decimal places. 

But if a decimal, then need two digits, two decimal places to the right.  If it rounds up to a single digit, that's fine too.

Translate
terryhendicott
21-Topaz II
Aug 26, 2025 1:24 AM UTC

Hi

This work around is not elegant but it works.

CTRW,"600"
PTRY,"2000"
ZLF,"17.87"
ZLR,"17.8"
79DTL,"PSV09 OR IN303"
3POID1,"600"

Translate
13-Aquamarine
Aug 26, 2025 8:49 PM UTC

Thank You!

Translate