cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-254339%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECols-Dienstprogramme%3A%20Wie%20kann%20%3CTEXT%20to%3D%22%22%20columns%3D%22%22%3E%20leere%20Daten%20verwalten%3F%3C%2FTEXT%3E%3CLINGO-BODY%20id%3D%22lingo-body-254339%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHallo%3C%2FP%3E%3CP%3EIch%20habe%20ein%20Problem%2C%20wenn%20ich%20%E2%80%9ECols-%26gt%3Butilities-%26gt%3Btext%20to%20columns%E2%80%9C%20verwende.%3C%2FP%3E%3CP%3EZum%20Beispiel%20habe%20ich%20die%20Daten%201%2C%20%2C2%2C3.%20Nachdem%20ich%20Text%20in%20Spalten%20geschrieben%20habe%2C%20m%C3%B6chte%20ich%20%7B1%7D%2C%7B%20%7D%2C%7B2%7D%2C%7B3%7D%20dieser%20vier%20Spalten%20erhalten%2C%20w%C3%A4hrend%20JMP%20mir%20%7B1%7D%2C%7B2%20gibt%20%7D%2C%7B3%7D%20wie%20unten%20im%20Screenshot.%3C%2FP%3E%3CP%3EExcel%20kann%20dies%20mit%20%3CTEXT%20in%3D%22%22%20spalten%3D%22%22%3E%20tun%3C%2FTEXT%3E%3C%2FP%3E%3CP%3EGibt%20es%20eine%20L%C3%B6sung%20in%20JMP%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDas%20Ergebnis%2C%20das%20ich%20von%20JMP%20erhalten%20habe%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22steven_gong_1-1585200437035.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22steven_gong_1-1585200437035.png%22%20style%3D%22width%3A%20374px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22steven_gong_1-1585200437035.png%22%20style%3D%22width%3A%20374px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F22567i3B1AA1F554F73EA0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22steven_gong_1-1585200437035.png%22%20alt%3D%22steven_gong_1-1585200437035.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Ewas%20ich%20erwartet%20habe%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22steven_gong_2-1585200470456.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22steven_gong_2-1585200470456.png%22%20style%3D%22width%3A%20384px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22steven_gong_2-1585200470456.png%22%20style%3D%22width%3A%20384px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F22568i565B0A486CB20A72%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22steven_gong_2-1585200470456.png%22%20alt%3D%22steven_gong_2-1585200470456.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-582374%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Cols-Dienstprogramme%3A%20Wie%20kann%20%3CTEXT%20to%3D%22%22%20columns%3D%22%22%3E%20leere%20Daten%20verwalten%3F%3C%2FTEXT%3E%3CLINGO-BODY%20id%3D%22lingo-body-582374%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20hatte%20k%C3%BCrzlich%20das%20gleiche%20Problem%20und%20fragte%20mich%2C%20ob%20dem%20Tool%20ein%20Kontrollk%C3%A4stchen%20hinzugef%C3%BCgt%20werden%20kann%3A%3CBR%20%2F%3E%20Dann%20kann%20der%20Benutzer%20selbst%20entscheiden%2C%20ob%20er%20die%20Funktion%20aktivieren%2Fdeaktivieren%20m%C3%B6chte%2C%20um%20mehrere%20Trennzeichen%20als%20ein%20einziges%20zu%20behandeln%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJMP-Wish-List%2FText-To-Columns-handle-missing-data-correctly%2Fm-p%2F582008%23U582008%22%20class%3D%22lia-mention-container-editor-message%20lia-img-icon-idea-thread%20lia-fa-icon%20lia-fa-idea%20lia-fa-thread%20lia-fa%22%20target%3D%22_blank%22%3EText%20in%20Spalten%3A%20Fehlende%20Daten%20korrekt%20behandeln%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-254731%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Cols-Dienstprogramme%3A%20Wie%20kann%20%3CTEXT%20to%3D%22%22%20columns%3D%22%22%3E%20leere%20Daten%20verwalten%3F%3C%2FTEXT%3E%3CLINGO-BODY%20id%3D%22lingo-body-254731%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EWenn%20Sie%20der%20Meinung%20sind%2C%20dass%20JMP%20%C3%BCber%20die%20Erweiterung%20verf%C3%BCgen%20sollte%2C%20f%C3%BCgen%20Sie%20sie%20bitte%20der%20JMP-Wunschliste%20hinzu%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-254730%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Cols-Dienstprogramme%3A%20Wie%20kann%20%3CTEXT%20to%3D%22%22%20columns%3D%22%22%3E%20leere%20Daten%20verwalten%3F%3C%2FTEXT%3E%3CLINGO-BODY%20id%3D%22lingo-body-254730%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHallo%20Jim%2C%3C%2FP%3E%3CP%3EWas%20f%C3%BCr%20eine%20Geschwindigkeit%2C%20so%20ein%20cooles%20Drehbuch%20abzuliefern!%3C%2FP%3E%3CP%3EVielen%20Dank.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C3%9Cbrigens%20denke%20ich%2C%20dass%20JMP%20m%C3%B6glicherweise%20dar%C3%BCber%20nachdenken%20muss%2C%20die%20Funktion%20von%20%3CTEXT%20in%3D%22%22%20spalten%3D%22%22%3E%20zu%20verbessern.%3C%2FTEXT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-254346%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Cols-Dienstprogramme%3A%20Wie%20kann%20%3CTEXT%20to%3D%22%22%20columns%3D%22%22%3E%20leere%20Daten%20verwalten%3F%3C%2FTEXT%3E%3CLINGO-BODY%20id%3D%22lingo-body-254346%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMir%20ist%20nicht%20bekannt%2C%20ob%20Sie%20mit%20der%20Funktion%20%E2%80%9EText%20in%20Spalten()%E2%80%9C%20das%20tun%2C%20was%20Sie%20wollen%2C%20aber%20hier%20ist%20eine%20einfache%20Funktion%2C%20die%20das%20tut%2C%20was%20Sie%20wollen%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20New%20Table(%20%22Example%22%2C%0A%20Add%20Rows(%203%20)%2C%0A%20New%20Column(%20%22string%22%2C%0A%20%20Character%2C%0A%20%20%22Nominal%22%2C%0A%20%20Set%20Values(%20%7B%221%2C2%2C3%22%2C%20%221%2C2%2C3%2C4%22%2C%20%221%2C%2C3%2C4%22%7D%20)%2C%0A%20%20Set%20Display%20Width(%2044%20)%0A%20)%0A)%3B%0A%0AnewTexttoColumns%20%3D%20Function(%7Bdt%2Cx%7D%2C%7Bdefaultlocal%7D%2C%0Astart%20%3D%20N%20Cols(%20dt%20)%3B%0AFor(%20theRow%20%3D%201%2C%20theRow%20%26lt%3B%3D%20N%20Rows(%20dt%20)%2C%20theRow%2B%2B%2C%0A%20theWord%20%3D%20%22%22%3B%0A%20wordCnt%20%3D%201%3B%0A%20For(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20Length(%20Column(%20x%20)%5BtheRow%5D%20)%2C%20i%2B%2B%2C%0A%20%0A%20%20If(%20Substr(%20Column(%20x%20)%5BtheRow%5D%2C%20i%2C%201%20)%20%3D%3D%20%22%2C%22%20%7C%20i%20%3D%3D%20Length(%20Column(%20x%20)%5BtheRow%5D%20)%2C%0A%20%20%20If(i%20%3D%3D%20Length(%20Column(%20x%20)%5BtheRow%5D)%2CtheWord%20%3D%20theWord%20%7C%7C%20Substr(%20Column(%20x%20)%5BtheRow%5D%2C%20i%2C%201%20))%3B%0A%20%20%20If(%20N%20Col(%20dt%20)%20%26lt%3B%20start%20%2B%20wordCnt%2C%0A%20%20%20%20dt%20%26lt%3B%26lt%3B%20New%20Column(%20%22%22%2C%20character%20)%0A%20%20%20)%3B%0A%20%20%20Column(%20start%20%2B%20wordCnt%20)%5BtheRow%5D%20%3D%20theWord%3B%0A%20%20%20wordCnt%2B%2B%3B%0A%20%20%20theWord%20%3D%20%22%22%3B%0A%20%20%2C%0A%20%20%20theWord%20%3D%20theWord%20%7C%7C%20Substr(%20Column(%20x%20)%5BtheRow%5D%2C%20i%2C%201%20)%0A%20%20)%0A%20%0A%20)%3B%0A)%3B%0A0%3B%0A)%3B%0A%0Areturn%20%3D%20newTexttoColumns(dt%2C%22string%22)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3C%2FLINGO-SUB%3E%3C%2FLINGO-SUB%3E%3C%2FLINGO-SUB%3E%3C%2FLINGO-SUB%3E%3C%2FLINGO-SUB%3E
Choose Language Hide Translation Bar
steven_gong
Level II

Cols utilities: how to let take care of empty data?

Hi

I got a problem when using Cols->utilities->text to columns.

For example I have data 1, ,2,3, after doing text to columns, I want to get {1},{ },{2},{3} these four columns, while JMP gives me {1},{2},{3} as below screen shot.

Excel can do this with <Text to Columns>

Is there an solution out there in JMP?

 

The result I got from JMP:

steven_gong_1-1585200437035.png

what I expected:

steven_gong_2-1585200470456.png

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Cols utilities: how to let take care of empty data?

I am not aware of doing what you want with the Text to Columns() function, but here is a simple function that will do what you want

Names Default To Here( 1 );
dt = New Table( "Example",
	Add Rows( 3 ),
	New Column( "string",
		Character,
		"Nominal",
		Set Values( {"1,2,3", "1,2,3,4", "1,,3,4"} ),
		Set Display Width( 44 )
	)
);

newTexttoColumns = Function({dt,x},{defaultlocal},
start = N Cols( dt );
For( theRow = 1, theRow <= N Rows( dt ), theRow++,
	theWord = "";
	wordCnt = 1;
	For( i = 1, i <= Length( Column( x )[theRow] ), i++,
	
		If( Substr( Column( x )[theRow], i, 1 ) == "," | i == Length( Column( x )[theRow] ),
			If(i == Length( Column( x )[theRow]),theWord = theWord || Substr( Column( x )[theRow], i, 1 ));
			If( N Col( dt ) < start + wordCnt,
				dt << New Column( "", character )
			);
			Column( start + wordCnt )[theRow] = theWord;
			wordCnt++;
			theWord = "";
		,
			theWord = theWord || Substr( Column( x )[theRow], i, 1 )
		)
	
	);
);
0;
);

return = newTexttoColumns(dt,"string");
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Cols utilities: how to let take care of empty data?

I am not aware of doing what you want with the Text to Columns() function, but here is a simple function that will do what you want

Names Default To Here( 1 );
dt = New Table( "Example",
	Add Rows( 3 ),
	New Column( "string",
		Character,
		"Nominal",
		Set Values( {"1,2,3", "1,2,3,4", "1,,3,4"} ),
		Set Display Width( 44 )
	)
);

newTexttoColumns = Function({dt,x},{defaultlocal},
start = N Cols( dt );
For( theRow = 1, theRow <= N Rows( dt ), theRow++,
	theWord = "";
	wordCnt = 1;
	For( i = 1, i <= Length( Column( x )[theRow] ), i++,
	
		If( Substr( Column( x )[theRow], i, 1 ) == "," | i == Length( Column( x )[theRow] ),
			If(i == Length( Column( x )[theRow]),theWord = theWord || Substr( Column( x )[theRow], i, 1 ));
			If( N Col( dt ) < start + wordCnt,
				dt << New Column( "", character )
			);
			Column( start + wordCnt )[theRow] = theWord;
			wordCnt++;
			theWord = "";
		,
			theWord = theWord || Substr( Column( x )[theRow], i, 1 )
		)
	
	);
);
0;
);

return = newTexttoColumns(dt,"string");
Jim
steven_gong
Level II

Re: Cols utilities: how to let take care of empty data?

Hi Jim,

What a speed to deliver such a cool script!

Thanks a lot.

 

BTW, I think JMP may need to consider to enhance the function of <text to columns>.

txnelson
Super User

Re: Cols utilities: how to let take care of empty data?

If you think JMP should have the enhancement, please add it to the JMP Wish List

Jim
hogi
Level XIII

Re: Cols utilities: how to let take care of empty data?

I recently had the same issue and wondered if a checkbox can be added to the tool:
Then the user can decide on his own if he wants to enable/disable the feature to treat multiple separator character as a single one:

 

Text To Columns: handle missing data correctly 

 

Recommended Articles