-
-
January 18, 2023 at 3:15 pm
Ermanno Manca
SubscriberHello,
I'm facing some problems using the *TREAD command. My problem is that displaying my table with the *STATUS command, gives me one less column and row of data.
I used the following code:
/INQUIRE,filelines,LINES,my_file_path,CSV ! Discover the number of lines in a text filenumlines = filelines-skiplines ! numlines = filelines - skiplines (here: 1)*DEL, read_csv,,NOPR*DIM, read_csv,TABLE,numlines-1,numcols-1 ! Create table array to hold data*TREAD, read_csv,fnames_input(1,1),CSV,,skiplines ! Import data into table*STATUS, read_csvI followed the instructions given here:https://simutechgroup.com/using-tread-in-ansys-mechanical-apdl-to-read-external-data/Because as described, entering the actual number of rows and columns for the relevant data leads to an unintentional shift of data.This is the content of the CSV in my_file_path:
Time Heatflux1 Heatflux2 Heatflux3 0 301 88 62 60 226.8 89 62 120 149 90 62 180 73 91 62 240 0 91 62 300 0 90 62 360 0 90 62 This is the output I get with the code described above:
LOCATION VALUE
1 1 1 226.800000
2 1 1 149.000000
3 1 1 73.0000000
4 1 1 0.00000000
5 1 1 0.00000000
6 1 1 0.00000000
1 2 1 89.0000000
2 2 1 90.0000000
3 2 1 91.0000000
4 2 1 91.0000000
5 2 1 90.0000000
6 2 1 90.0000000
1 3 1 62.0000000
2 3 1 62.0000000
3 3 1 62.0000000
4 3 1 62.0000000
5 3 1 62.0000000
6 3 1 62.0000000Is there any way to get the first row and column included in my table without changing the csv-file?
Thanks a lot in advance.
-
January 23, 2023 at 4:32 pm
Mike Rife
Ansys EmployeeHi Ermanno Manca
Just like there is a zeroth column (that holds the time data in your example) there is a zeroth row that needs data since you have more than one column. The '301, 88, 62' row is going to that zeroth row.
The example from the SimuTech page shows this but watch out as the first multi-column data screen shot is a little wrong/odd as the spreadsheet data does not match the text file nor APDL screenshot data. But idea is discussed.
MIke
-
January 23, 2023 at 4:37 pm
Dave Looman
Ansys Employee*TREAD treats the data as an indexed array. Column 0 and row 0 are the indices. Since your first row of data was read in as row 0 you can include it in the *status output with *status,0,N
-
January 23, 2023 at 4:42 pm
Dave Looman
Ansys EmployeeAlso, the APDL gui is useful to review the *TREAD input. In the top toolbar use Parameters> Array Parameters> Define/Edit...
-
January 24, 2023 at 6:56 am
mjmiddle
Ansys EmployeeA key concept with table arrays is that indices are real numbers, but only when retrieving table values, not when setting. You do not use the same index entries when retrieving as when setting. The zero row, column is where the real-number index is stored. Simple example:
*DIM,springvari,TABLE,4,1,1,TIME,
! Time values
springvari(1,0) = 0.0 ! table row (retrieve-row) index set to zero column
springvari(2,0) = 1.0 ! table index
springvari(3,0) = 1.5 ! table index
springvari(4,0) = 2.0 ! table index
! Load values
springvari(1,1) = 50.0
springvari(2,1) = 50.0
springvari(3,1) = 275.0
springvari(4,1) = 500.0The above is actually a 1-dimensional array, so the second index would normally not be used in regular arrays. Do not use the same index entries when retrieving as when setting:
/com, %springvari(3,1)% ! do not do this. It is past the maximum range and will return the max value 500
! do this:
/com, %springvari(1.5,1)% ! returns 275.0. Note that you set index (3,1) to this value but used (1.5,1) to retrieve
/com, %springvari(1.75,1)% ! returns 387.5 (linear interpolated)
! or just do this since it is really meant to be a 1-dimensional array:
/com, %springvari(1.75)% ! returns 387.5
! you can't return the index numbers set as table entries:
/com, %springvari(3,0)% ! the second index is ignored since it's meant to be a 1D array. So same as %springvari(3)% which returns max value (500) since it is past the max index 2.0-
January 24, 2023 at 10:33 am
Ermanno Manca
SubscriberThank you so much for the explanation and the example.
Is there any other way to get the same index entries when retrieving as when setting while working with CSV files?
So that the zeroth column and row are not used as indices?
-
-
January 24, 2023 at 7:07 am
mjmiddle
Ansys EmployeeTwo dimensional example:
If both row and column are greater than 1, the zero row and zero column are indices, so you will dimension row and column as one-less than number of rows and columns seen in the data file. The first row in the file is the column indices. The first column in the file is the row indices.
Example:
filename='datafile'
ncols = 3
*sread,newstr,%filename%,txt
*get,nlines,parm,newstr,dim,2 ! nlines will be 4 from data file below
*dim,t300,table,nlines-1,ncols-1
*tread,t300,%filename%,txt
! empty lines at the end of file will hurt this setup, since it will dimension based on number of lines.File "datafile.txt":
0,1.1,2.5
0.002,0.0017787,5
0.004,0.0025841,7
0.006,0.0033896,10Indices must be ascending order, so this applies to data in the first row and first column.
*tread can use data as comma, tab, or space delimited. Most all other code in APDL won't use tabs.
The first row and first column of data will not be seen when printing out the array since these are used as the indices.
When you get the data with *status, it will look like this:
row, col, value
1, 1, 0.0017787
2, 1, 0.0025841
3, 1, 0.0033896
1, 2, 5
2, 2, 7
3, 2, 10The *tread will set up indices like this:
t300(1,0) = 0.002
t300(2,0) = 0.004
t300(3,0) = 0.006
t300(0,0) = 0 ! not sure if this can be used
t300(0,1) = 1.1
t300(0,2) = 2.5data is set up like this as rows, cols seen from *status above:
t300(1,1) = 0.0017787
t300(2,1) = 0.0025841
t300(3,1) = 0.0033896
t300(1,2) = 5
t300(2,2) = 7
t300(3,2) = 10
-
- You must be logged in to reply to this topic.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Saving & sharing of Working project files in .wbpz format
- An Unknown error occurred during solution. Check the Solver Output…..
- Understanding Force Convergence Solution Output
- Solver Pivot Warning in Beam Element Model
- Colors and Mesh Display
- How to calculate the residual stress on a coating by Vickers indentation?
- whether have the difference between using contact and target bodies
- What is the difference between bonded contact region and fixed joint
- The solver engine was unable to converge on a solution for the nonlinear problem as constrained.
- User manual
-
2524
-
2066
-
1279
-
1096
-
457
© 2023 Copyright ANSYS, Inc. All rights reserved.