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%3EFeldende%20(andere)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54451%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIch%20habe%20eine%20Datei%20(im%20Wesentlichen%20eine%20Textdatei%2C%20aber%20mit%20.log%20als%20Erweiterung).Es%20ist%20durch%20Kommas%20getrennt.Enth%C3%A4lt%20sowohl%20Zeichen-%20als%20auch%20numerische%20Daten.Hin%20und%20wieder%20bekomme%20ich%20eine%20ID-Nummer%20mit%20einem%20Komma%20drin.Das%20wirft%20die%20S%C3%A4ulen%20ab.Wenn%20ich%20mir%20die%20Daten%20ansehe%2C%20sehe%20ich%2C%20dass%20alle%20Werte%2C%20die%20ich%20trennen%20m%C3%B6chte%2C%20tats%C3%A4chlich%20ein%20Leerzeichen%20nach%20dem%20Komma%20haben.%20Ich%20m%C3%B6chte%20die%20Spalten%20mit%20etwas%20wie%20folgt%20trennen%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%3EDie%20Datentabelle%20ist%20jedoch%20immer%20noch%20durch%20Kommas%20getrennt%2C%20sodass%20die%20Werte%2C%20die%20ich%20nicht%20trennen%20m%C3%B6chte%2C%20in%202%20Spalten%20getrennt%20sind.%20Gibt%20es%20eine%20M%C3%B6glichkeit%2C%20das%20Komma%20in%20einem%20Wert%20wie%2012345%2C6%20zu%20ignorieren%2C%20aber%20die%20Trennzeichen%20mit%20einem%20Leerzeichen%20nach%20%22%2C%20%22%20beizubehalten%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EVielen%20Dank%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%3EBetreff%3A%20Feldende%20(andere)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54472%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Edas%20hat%20sehr%20gut%20funktioniert%2C%20danke%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-54458%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Feldende%20(andere)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-54458%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESie%20k%C3%B6nnten%20die%20Textdatei%20selbst%20vorverarbeiten%2C%20um%20sie%20alle%20in%20Registerkarten%20zu%20%C3%A4ndern%2C%20und%20dann%20einfach%20wie%20ein%20TSV%20importieren%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