I am having data in a txt file .
What is the best option to read in the data into a JMP table with skipping the # character to get the column names fitting to the data columns?
Any recommendations ?
Hi @mlo1,
I don't know of a non-scripting way during import to ignore a character like that. Preprocessing the file to remove the # is probably the most direct approach if you can do it. I've been in a situation like this before where editing the original file wasn't possible/preferable, and so another approach would be to fix the names after the import. The following shifts all the column names left and removes the blank last column.
dt = Current Data Table();
//get all the column names
colNames = dt << Get Column Names( String );
//remove the last column with no data
dt << Delete Columns( N Cols( dt ) );
//loop to replace names starting at the end of the table
For( c = N Cols( dt ), c > 0, c--,
Column( c ) << Set Name( colNames[c+1] )
);
I hope this helps!
Here is other option which relies on removing few extra characters and then "opening the file" again by using Char To Blob()
Names Default To Here(1);
txt = Load Text File("$DOWNLOADS/JMPTest.txt");
txt = Substr(txt, 3, - 1); // drop first three characters
dt = Open(
Char To Blob(txt),
End Of Field(Spaces, Space, CSV(0))
);
Could you share the text file (or mock-up of it)? Makes it much easier to provide suggestions. First idea that comes to my mind is to drop some characters from the data with the help of JSL
Thank you for the reply I enclosed a sample file.
Hi @mlo1,
I don't know of a non-scripting way during import to ignore a character like that. Preprocessing the file to remove the # is probably the most direct approach if you can do it. I've been in a situation like this before where editing the original file wasn't possible/preferable, and so another approach would be to fix the names after the import. The following shifts all the column names left and removes the blank last column.
dt = Current Data Table();
//get all the column names
colNames = dt << Get Column Names( String );
//remove the last column with no data
dt << Delete Columns( N Cols( dt ) );
//loop to replace names starting at the end of the table
For( c = N Cols( dt ), c > 0, c--,
Column( c ) << Set Name( colNames[c+1] )
);
I hope this helps!
Here is other option which relies on removing few extra characters and then "opening the file" again by using Char To Blob()
Names Default To Here(1);
txt = Load Text File("$DOWNLOADS/JMPTest.txt");
txt = Substr(txt, 3, - 1); // drop first three characters
dt = Open(
Char To Blob(txt),
End Of Field(Spaces, Space, CSV(0))
);
If you don't want to script this, it's pretty easy to deal with moving the column names after the table is opened.
Note that the selection of the columns in the columns list on the left is the important bit. That puts the keyboard focus in that list so that Copy and Paste get the column names and not the data from the data table.
@Jeff_Perkinson 's approach is very elegant ...
if you are interested in more such easter eggs in Jmp, you can have a look at this list:
CTRL/Alt/Shift + click/select/double click/right click
I guess there are hundreds more - just waiting till some user finds them