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%3EEnd%20Of%20Field%20(altro)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54451%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHo%20un%20file%20(essenzialmente%20un%20file%20di%20testo%20ma%20con%20.log%20come%20estensione).%26nbsp%3B%20%C3%88%20una%20virgola%20separata.%26nbsp%3B%20Contiene%20sia%20caratteri%20che%20dati%20numerici.%26nbsp%3B%20Ogni%20tanto%20ricevo%20un%20numero%20ID%20con%20una%20virgola.%26nbsp%3B%20Questo%20getta%20via%20le%20colonne.%26nbsp%3B%20osservando%20i%20dati%20vedo%20che%20tutti%20i%20valori%20che%20voglio%20separare%20hanno%20effettivamente%20uno%20spazio%20dopo%20la%20virgola.%20Voglio%20separare%20le%20colonne%20con%20qualcosa%20di%20simile%20a%20questo%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%3ETuttavia%2C%20la%20tabella%20dei%20dati%20%C3%A8%20ancora%20delimitata%20da%20virgola%20in%20modo%20che%20i%20valori%20che%20non%20desidero%20essere%20delimetati%20siano%20separati%20in%202%20colonne.%20C'%C3%A8%20un%20modo%20per%20ignorare%20la%20virgola%20in%20un%20valore%20come%2012345%2C6%20ma%20mantenere%20i%20delimitatori%20che%20hanno%20uno%20spazio%20dopo%20di%20essi%20%22%2C%22%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGrazie%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%20End%20Of%20Field%20(altro)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Eha%20funzionato%20molto%20bene%2C%20grazie%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%20End%20Of%20Field%20(altro)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54458%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Epuoi%20preprocessare%20il%20file%20di%20testo%20stesso%20per%20cambiarli%20tutti%20in%20schede%2C%20quindi%20importare%20come%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