cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Remove "" from TEXT FILE

ppal
17-Peridot

Remove "" from TEXT FILE

Prime 9 File attached.

ppal_0-1682651631821.png

 

ACCEPTED SOLUTION

Accepted Solutions


@terryhendicott wrote:

Hi,

WRITEPRN in Mathcad 15 used to do exactly that but for unknown reasons they changed it for Prime?


WRITEPRN is still available in Prime and works the same way as in MC15 - it does not remove the quote character either and additionally adds some header information at the top.

WRITETEXT is new in Prime and should have been implemented in a way so that at least you have a choice to remove the quotes.

It was a long standing wish for Mathcad to be able to create true text files in an easy and intuitive way but the only way to accomplish that was using the WRITEBIN function.

 

Here is a brute force workaround - a user defined function WRITETXT2() which uses WRITETXT to write the file, reads it in again via READBIN, removes all quote character (#34) and rewrites the file via WRITEBIN.

Should work well as long as the strings don't contain quote characters themselves!

Werner_E_0-1682664619512.png

 

View solution in original post

8 REPLIES 8

Hi,

WRITEPRN in Mathcad 15 used to do exactly that but for unknown reasons they changed it for Prime?

 

Here is a workaround that does what Mathcad 15 used to produce.  It creates a binary file which is nothing but a collection of bytes that can be read by an editor like Notepad.  It creates an extra line at the top but you can delete this in the text editor.  It generates spaces (character 32) between the items but could be adjusted to do tabs (character 9) in between if required.

 

Capture.JPG

 

Capture2.JPG

Cheers

Terry

 

 


@terryhendicott wrote:

Hi,

WRITEPRN in Mathcad 15 used to do exactly that but for unknown reasons they changed it for Prime?


WRITEPRN is still available in Prime and works the same way as in MC15 - it does not remove the quote character either and additionally adds some header information at the top.

WRITETEXT is new in Prime and should have been implemented in a way so that at least you have a choice to remove the quotes.

It was a long standing wish for Mathcad to be able to create true text files in an easy and intuitive way but the only way to accomplish that was using the WRITEBIN function.

 

Here is a brute force workaround - a user defined function WRITETXT2() which uses WRITETXT to write the file, reads it in again via READBIN, removes all quote character (#34) and rewrites the file via WRITEBIN.

Should work well as long as the strings don't contain quote characters themselves!

Werner_E_0-1682664619512.png

 

@terryhendicott wrote:
Hi,

WRITEPRN in Mathcad 15 used to do exactly that but for unknown reasons they changed it for Prime?

 

What I meant to say is a data export wizard existed in Mathcad 15 that outputted a formatted text file in PRN format from a matrix.

numbers remained numbers, single quoted text was written as text without quotes, double quoted text was written as single quoted text.

 

I miss this utility in Prime.

 

Capture.JPG

Capture2.JPG

Capture4.jpg

Cheers

Terry


@terryhendicott wrote:

@terryhendicott wrote:
Hi,

WRITEPRN in Mathcad 15 used to do exactly that but for unknown reasons they changed it for Prime?

 

What I meant to say is a data export wizard existed in Mathcad 15 that outputted a formatted text file in PRN format from a matrix.

numbers remained numbers, single quoted text was written as text without quotes, double quoted text was written as single quoted text.

 

I miss this utility in Prime.

 

 


Ah, I see. I think I never used that feature, but I sure miss data-table from that very same menu.

There is this in the help:

I don't know how to implement.

 

options (optional) is a 3 x 1 column vector structured from top to bottom as 'txtqual', 'decsymb', 'thousep':
txtqual (text qualifier)—You can specify double quotes (default), single quote, or none.
decsymb (decimal symbol)—You can specify either "," (comma) or "." (dot). Dot is the default.
thousep (thousands separator)—You can specify either "," (comma), "." (dot) or " " (space). Comma is the default.
Werner_E
25-Diamond I
(To:ppal)

These "options" are only available for reading with READTEXT( ) to tell Prime what the delimiters of text strings in the (already existing) file ar or if everything should be interpreted as text.

So this won't help you as you'd like to create a file using WRITETXT( ).

So I guess you will have to resort to either Terrys AssemblePRN ( )  or my WRITETXT2 ( ).

WRITETXT2 ( ) can't be used if your textstrings contain the double quotes themselves.

This could be fixed, but would increase the functions size as we would have to look if a quote is either the first or last character in the file or if its followed or prepended by a TAB or CRLF before we can remove it.

Hi,

You could also just use a text editor and replace " with nothing.

Cheers

Terry

JeffH1
16-Pearl
(To:ppal)

There was a sample worksheet some time ago for converting Mathcad matrices to C++ code. They ran into the same problem with the double quotes and wrote a cool function that converts the matrix strings to binary vectors (using the string to vector function, str2vec) to encode everything as binary arrays and then write the arrays to a file using WRITEBIN(), which writes binary to a file with no formatting (like adding the double quotes).

 

Here's the User Function (slightly modified from the original) to output the matrix to a text file with no double quotes:

JeffH1_0-1682874927224.png

 

Use the function as follows:

JeffH1_1-1682874987796.png

I've attached an update to your sequencer worksheet here that demonstrates this function (in Prime 9 format, since that's what you uploaded).

 

Announcements

Top Tags