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(other)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54451%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EI%20have%20a%20file%20(essentially%20a%20text%20file%20but%20with%20.log%20as%20the%20extension).%26nbsp%3B%20It%20is%20comma%20seperated.%26nbsp%3B%20Contains%20both%20character%20and%20numeric%20data.%26nbsp%3B%20Every%20now%20and%20then%20I%20get%20a%20ID%20number%20with%20a%20comma%20in%20it.%26nbsp%3B%20This%20throws%20the%20columns%20off.%26nbsp%3B%20looking%20at%20the%20data%20I%20see%20that%20all%20the%20values%20I%20want%20to%20seperaate%20actually%20have%20a%20space%20after%20the%20comma.%20I%20want%20to%20seperate%20the%20columns%20with%20something%20like%20this%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%3EHowever%2C%20the%20data%20table%20is%20still%20comma%20delimeted%20so%20that%20the%20values%20I%20do%20not%20want%20to%20be%20delimeted%20are%20seperated%20into%202%20columns.%20Is%20there%20a%20way%20to%20ignore%20the%20comma%20in%20a%20value%20such%20as%2012345%2C6%20but%20keep%20the%20delimeters%20that%26nbsp%3Bhave%20a%20space%20after%20them%20%22%2C%20%22%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%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(other)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Ethat%20worked%20very%20nicely%2C%20thanks%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(other)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54458%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Eyou%20could%20preprocess%20the%20text%20file%20itself%20to%20change%20all%20of%20them%20to%20tabs%20then%20just%20import%20like%20a%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