- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to Skip charater to import column header
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 ?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
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))
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
Thank you for the reply I enclosed a sample file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
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))
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
If you don't want to script this, it's pretty easy to deal with moving the column names after the table is opened.
- Select columns 2 through n (i.e., the last column in the table) in the columns list on the left side of the data table, then Ctrl-C or Edit->Copy and you'll copy the column names to the clipboard.
- Then, delete the last column of the data table, otherwise you'll end up with a duplicate column name.
- Finally, select all the columns the columns list and Ctrl-V or Edit->Paste and you'll paste the column names you just copied.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to Skip charater to import column header
@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