Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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?
Solved! Go to Solution.
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.
Delimiter between columns would be a comma.
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 🙂 )
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
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.
Exactly what I wanted! dummy :=WRITECUSTOM("trial.txt",P). Works!
Is there a purpose for the line filename:=".\test.csv"
After I stared at the programming, I'm pretty sure I understand up to the last two lines of your coding. Can you provide a little help there?
Thank you again.
If I wanted to add that the first row, column 1 is [XX] and the second column first row is just a blank, how would I do that without manually plugging that in? It would be a good reminder for the engineer to fill in the XX for the end point device purpose. It's not always the same.
@Snowshoeman wrote:
If I wanted to add that the first row, column 1 is [XX] and the second column first row is just a blank, how would I do that without manually plugging that in? It would be a good reminder for the engineer to fill in the XX for the end point device purpose. It's not always the same.
You can let WRITECUSTOM do the job. It also makes the last line simpler as we don't have to get rid of the dummy NaN which I used to initialize the vector v.
But if you need that line in the worksheet, you simply could use the "stack" function:
Thanks! I will give that a try. The motherboard on the computer with Prime died. So, it will be a day or two before I get back to this.
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"
Thank You!