Skip to main content
13-Aquamarine
August 25, 2025
Solved

Write a comma delimited Text file

  • August 25, 2025
  • 3 replies
  • 3701 views

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?

Best answer by Snowshoeman

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.

3 replies

13-Aquamarine
August 25, 2025

Delimiter between columns would be a comma.

25-Diamond I
August 26, 2025

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 🙂 )

25-Diamond I
August 26, 2025

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

Snowshoeman13-AquamarineAuthorAnswer
13-Aquamarine
August 26, 2025

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.

21-Topaz II
August 26, 2025

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"

13-Aquamarine
August 26, 2025

Thank You!