cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ron_horne
Super User (Alumni)

importing from excel with a new line in a cell

Dear Members of the community,

Does anyone know how to import data from excel correctly when there are line brakes within cells?

in the attached excel sheet, cells B4 and B7 have a line brake that makes the import incorrect no matter how i try to import or just copy and paste into JMP. Is there an importing method that is robust to this?

 

line brakes can be entered into a cell in excel using Alt+Enter or if more than one paragraph is copied from other programs. It throws a spanner in the works and with large files causes havoc.

i am using JMP 14 but i do not think it is a version issue.

Many thanks,

Ron

2 ACCEPTED SOLUTIONS

Accepted Solutions
Byron_JMP
Staff

Re: importing from excel with a new line in a cell

I just had this problem last week, drove me nuts!

I threw in some recode after the import to collapse whitespace and that fixed it.

 

Names Default To Here( 1 );
dt = Data Table( "Sheet1" );
dt << Begin Data Update;
dt << Recode Column(
	dt:Nominal,
	{Collapse Whitespace( _rcNow )},
	Target Column( :Nominal )
);
dt << End Data Update;
JMP Systems Engineer, Health and Life Sciences (Pharma)

View solution in original post

Byron_JMP
Staff

Re: importing from excel with a new line in a cell

I opened your Excel file with the Excel Import Wizard.

Then used both Recode as well as a formula to collapse whitespace

Screen Shot 2021-02-01 at 2.20.23 PM.png

Both approaches use the same function. Although the function is called Collapse Whitespace, it might as well be called, One space between each alphanumeric symbol in a string.

 

Although we aren't talking MS stuff here, diagnosing the issue in the Excel sheet is more important because it is a data entry error there, as well as a source of miserable problems in Excel too. The hard return can either look like a no space at all, or maybe a space if the wrap role it turned on. Either way its a S in S out kind of problem.

JMP Systems Engineer, Health and Life Sciences (Pharma)

View solution in original post

5 REPLIES 5
Byron_JMP
Staff

Re: importing from excel with a new line in a cell

I just had this problem last week, drove me nuts!

I threw in some recode after the import to collapse whitespace and that fixed it.

 

Names Default To Here( 1 );
dt = Data Table( "Sheet1" );
dt << Begin Data Update;
dt << Recode Column(
	dt:Nominal,
	{Collapse Whitespace( _rcNow )},
	Target Column( :Nominal )
);
dt << End Data Update;
JMP Systems Engineer, Health and Life Sciences (Pharma)
ron_horne
Super User (Alumni)

Re: importing from excel with a new line in a cell

Thank you  @Byron_JMP for your suggestion. But it didn't work in my case, perhaps we have different import settings.

 

my original table in excel looks like this, with line brakes in cells B4 and B7

ron_horne_0-1612196517229.png

 

using the on the fly copy and paste with column names i get the following image. where every line brake is interpenetrated as a new table row,

ron_horne_1-1612196627195.png

 

using the import wizard i get the following where the original line brakes within the cells have been removed together with the reminder of its content.

ron_horne_2-1612196797987.png

 

Therefore, I do not get a whitespace which its removal would solve anything.

 

Ideally, this could be fixed within JMP as part of the way it reads the data while importing. JMP should

Interpret this as either a new line within a cell or just a space between characters.

 

when opening the excel file in SAS using default settings, the result is much better. The line brake in the cell was just removed. This maintains the overall integrity of the cells, rows and columns of the file.

Iit would have been better to add a space though. Not sure how i would be able to add it myself later if i had to use the text for analysis.

ron_horne_0-1612204506067.png

 

 

the way i did manage to solve it so far is by searching and replacing all the new lines in Excel prior to the import. the new line character to search for in excel is Ctrl+j. replacing it with a simple space has given me the the least confusing outcome.

 

Hope you can address this to the right person to fix it in future versions of the program.

 

If anyone has other solutions please do share. I am sure many files imported from excel and other formats that allow for line brakes within a cell has produced imperfect data sets.

 

 

 

Byron_JMP
Staff

Re: importing from excel with a new line in a cell

I opened your Excel file with the Excel Import Wizard.

Then used both Recode as well as a formula to collapse whitespace

Screen Shot 2021-02-01 at 2.20.23 PM.png

Both approaches use the same function. Although the function is called Collapse Whitespace, it might as well be called, One space between each alphanumeric symbol in a string.

 

Although we aren't talking MS stuff here, diagnosing the issue in the Excel sheet is more important because it is a data entry error there, as well as a source of miserable problems in Excel too. The hard return can either look like a no space at all, or maybe a space if the wrap role it turned on. Either way its a S in S out kind of problem.

JMP Systems Engineer, Health and Life Sciences (Pharma)
ron_horne
Super User (Alumni)

Re: importing from excel with a new line in a cell

Thank you very much @Byron_JMP 

I have now noticed that the import did work, i just needed to increase the height of the rows to see it properly.

 

 

Byron_JMP
Staff

Re: importing from excel with a new line in a cell

Whew!  Super glad I wasn't going crazy there. : )

JMP Systems Engineer, Health and Life Sciences (Pharma)