Skip to main content
13-Aquamarine
August 6, 2026
Question

Matrix to unlinked matrix

  • August 6, 2026
  • 20 replies
  • 313 views

I would like to READTEXT from text file which would form a two-column matrix.  That part is easy.  Then I would like to copy the contents of the first matrix to a second matrix, then use that second matrix for other purposes, but unlinked to the first matrix.

20 replies

21-Topaz II
August 30, 2026

Hi,

Do you only want the values in [R1] section or do you need [INFO] section as well?

Are there other sections [R2] etc?

 

Python can easily read the text file into a two column Python matrix of strings  and can using other python files create a matrix in Prime from this python matrix.  Hence no link in Prime data to original data from text file.

Would this do?  Takes only three Python lines to create the Prime worksheet!

import configparser
import numpy as np
from prime_writer import *

config = configparser.ConfigParser(strict=False, delimiters=('=', ','))
config.read('SET_R1.txt')

# 1. Create an empty list to act as your matrix
r1_matrix = []

# 2. Loop through the R1 section items
if 'R1' in config:
for key, value in config.items('R1'):
# Keep keys uppercase to match your file style
col1 = key.upper()

# Clean the value and force it to stay a string
col2 = str(value).strip('" ')

# Append as a two-item row [Column 1, Column 2]
r1_matrix.append([col1, col2])

# Convert to a NumPy array of strings
r1_array = np.array(r1_matrix, dtype='U')

# Check the results of read and conversion
print("Array Output:")
print(r1_array)

# Print size of array
print("\nArray Shape:", r1_array.shape[0], r1_array.shape[1])

# Use prime_writer to create Prime File
ws = Worksheet()
ws.Define('R1',r1_array)

# Replace these names with your actual template/output paths.
ws.SaveUsingTemplate('C:\\TEMP\\uploadedPrime10File.mcdx', 'PythonExample.mcdx')
print('Created PythonExample.mcdx')

Python is free.

configparser comes as part of python

numpy needs an additional install and is also free

 

Cheers

Terry

13-Aquamarine
August 30, 2026

This would work! 

Did you write the prime files in 12.  My org has only approved 11, so I can’ read your file.

21-Topaz II
August 31, 2026

Sorry, was posting from a system, not mine, with Prime 12.  These are Prime 10. 

The resulting Prime File is the same Prime version as the template/donor file.  A Prime worksheet is a zipped collection of XML files.  To make the python writer simpler a template worksheet is used to donate a number of these consistent XML files instead of creating them from scratch.  The actual math content of this donating worksheet is not used in the created worksheet.  The resulting worksheet file is the version of the donating worksheet.  Have tried this with PTC Prime 9, 10, and 11. 

You can construct your own donor file in Prime 11.  Its only contents are:  It is important no text block or boxes in donor file.  It is important no evaluation equals in the donor file.  These add XML files to a Prime Archive.

 

13-Aquamarine
September 15, 2026

my org does not allow install of numpy.