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-54451%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EFin%20de%20campo%20(otro)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54451%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ETengo%20un%20archivo%20(esencialmente%20un%20archivo%20de%20texto%20pero%20con%20.log%20como%20extensi%C3%B3n).Est%C3%A1%20separado%20por%20comas.Contiene%20caracteres%20y%20datos%20num%C3%A9ricos.De%20vez%20en%20cuando%20recibo%20un%20n%C3%BAmero%20de%20identificaci%C3%B3n%20con%20una%20coma.Esto%20arroja%20las%20columnas%20fuera.Al%20mirar%20los%20datos%2C%20veo%20que%20todos%20los%20valores%20que%20quiero%20separar%20en%20realidad%20tienen%20un%20espacio%20despu%C3%A9s%20de%20la%20coma.%20Quiero%20separar%20las%20columnas%20con%20algo%20como%20esto%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EFor(%20i%20%3D%201%20%2C%20i%20%26lt%3B%3D%20nf%2C%20i%2B%2B%2C%0Afilenow%20%3D%20(%20filelist%5Bi%5D%20)%3B%0Afileopen%3D(filepath%7C%7Cfilenow)%3B%0A%0Adt%3Dopen(fileopen%2C%20%22text%22%2C%20End%20Of%20Field(Other)%2C%20EOF%20Other(%22%2C%20%22)%2C%20Table%20Contains%20Column%20Headers(%200%20))%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESin%20embargo%2C%20la%20tabla%20de%20datos%20todav%C3%ADa%20est%C3%A1%20delimitada%20por%20comas%2C%20por%20lo%20que%20los%20valores%20que%20no%20quiero%20delimitar%20se%20separan%20en%202%20columnas.%20%C2%BFHay%20alguna%20manera%20de%20ignorar%20la%20coma%20en%20un%20valor%20como%2012345%2C6%20pero%20mantener%20los%20delimitadores%20que%20tienen%20un%20espacio%20despu%C3%A9s%20de%20ellos%20%22%2C%20%22%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGracias%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-54472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Fin%20del%20campo%20(otro)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Eeso%20funcion%C3%B3%20muy%20bien%2C%20gracias%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-54458%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Fin%20del%20campo%20(otro)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54458%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Epodr%C3%ADa%20preprocesar%20el%20archivo%20de%20texto%20en%20s%C3%AD%20mismo%20para%20cambiarlos%20todos%20a%20pesta%C3%B1as%20y%20luego%20simplemente%20importarlos%20como%20un%20tsv%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20to%20here(1)%3B%0Afile%20%3D%20pick%20file()%3B%0Atxt%20%3D%20load%20text%20file(file)%3B%0Asubstitute%20into(txt%2C%20%22%2C%20%22%2C%20%22%5C!t%22)%3B%0Anewfile%20%3D%20convert%20file%20path(%22%24TEMP%2Ftempfile.log%22)%3B%0Asave%20text%20file(newfile%2C%20txt)%3B%0A%0A%0Adt%3Dopen(newfile%2C%20%22text%22%2C%20End%20Of%20Field(%22Tab%22)%2C%20Table%20Contains%20Column%20Headers(%200%20))%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
KST-CPT
Level II

End Of Field(other)

I have a file (essentially a text file but with .log as the extension).  It is comma seperated.  Contains both character and numeric data.  Every now and then I get a ID number with a comma in it.  This throws the columns off.  looking at the data I see that all the values I want to seperaate actually have a space after the comma. I want to seperate the columns with something like this:

 

For( i = 1 , i <= nf, i++,
filenow = ( filelist[i] );
fileopen=(filepath||filenow);

dt=open(fileopen, "text", End Of Field(Other), EOF Other(", "), Table Contains Column Headers( 0 ));

 

However, the data table is still comma delimeted so that the values I do not want to be delimeted are seperated into 2 columns. Is there a way to ignore the comma in a value such as 12345,6 but keep the delimeters that have a space after them ", "?

 

Thanks

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User (Alumni)

Re: End Of Field(other)

you could preprocess the text file itself to change all of them to tabs then just import like a tsv

 

Names Default to here(1);
file = pick file();
txt = load text file(file);
substitute into(txt, ", ", "\!t");
newfile = convert file path("$TEMP/tempfile.log");
save text file(newfile, txt);


dt=open(newfile, "text", End Of Field("Tab"), Table Contains Column Headers( 0 ));
Vince Faller - Predictum

View solution in original post

2 REPLIES 2
vince_faller
Super User (Alumni)

Re: End Of Field(other)

you could preprocess the text file itself to change all of them to tabs then just import like a tsv

 

Names Default to here(1);
file = pick file();
txt = load text file(file);
substitute into(txt, ", ", "\!t");
newfile = convert file path("$TEMP/tempfile.log");
save text file(newfile, txt);


dt=open(newfile, "text", End Of Field("Tab"), Table Contains Column Headers( 0 ));
Vince Faller - Predictum
KST-CPT
Level II

Re: End Of Field(other)

that worked very nicely, thanks

Recommended Articles