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-909378%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EProbl%C3%A8me%20d'importation%20de%20donn%C3%A9es%20%C3%A0%20partir%20d'un%20fichier%20texte%3C%2FLINGO-SUB%3E%0A%20%20%3CLINGO-BODY%20id%3D%22lingo-body-909378%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%20%20%20%3CP%3ENous%20rencontrons%20des%20probl%C3%A8mes%20lors%20de%20l'importation%20de%20donn%C3%A9es%20depuis%20un%20fichier%20texte.%20Un%20message%20d'erreur%20s'affiche%20pour%20certaines%20colonnes%20(%C2%AB%26nbsp%3BDonn%C3%A9es%20non%20valides%20rencontr%C3%A9es%20lors%20de%20l'importation%20de%20la%20colonne...%20R%C3%A9essayez%20d'importer%20les%20donn%C3%A9es%2C%20mais%20d%C3%A9finissez%20explicitement%20le%20type%20de%20donn%C3%A9es%20de%20ces%20colonnes%20sur%20Caract%C3%A8re%26nbsp%3B%C2%BB).%3C%2FP%3E%20%0A%20%20%20%3CP%3EPour%20plus%20de%20clart%C3%A9%2C%20nous%20utilisons%20un%20script%20JMP%20pour%20extraire%20un%20ensemble%20de%20donn%C3%A9es%20d'une%20base%20de%20donn%C3%A9es.%20Apr%C3%A8s%20l'extraction%2C%20les%20donn%C3%A9es%20sont%20organis%C3%A9es%20avec%20des%20param%C3%A8tres%20en%20colonnes%20et%20en%20lignes%20pour%20chaque%20instance%20de%20donn%C3%A9es.%20Ces%20param%C3%A8tres%20sont%20tous%20cat%C3%A9goriques%2C%20mais%20beaucoup%20sont%20num%C3%A9riques%20(et%20beaucoup%20sont%20format%C3%A9s%20en%20date).%20Il%20y%20a%20quelques%20ann%C3%A9es%2C%20nous%20avons%20demand%C3%A9%20de%20l'aide%20pour%20am%C3%A9liorer%20les%20performances%20(temps)%20de%20conversion%20de%20toutes%20les%20colonnes%20au%20type%20de%20donn%C3%A9es%20appropri%C3%A9%20(l'utilisation%20du%20script%20JMP%20prenait%20beaucoup%20de%20temps%20en%20raison%20des%20milliers%20de%20colonnes).%3C%2FP%3E%20%0A%20%20%20%3CP%3EJim%20Nelson%20a%20sugg%C3%A9r%C3%A9%20d'enregistrer%20le%20tableau%20au%20format%20texte%2C%20puis%20de%20le%20rouvrir.%20Cela%20a%20bien%20fonctionn%C3%A9%2C%20am%C3%A9liorant%20consid%C3%A9rablement%20les%20performances%2C%20convertissant%20toutes%20les%20colonnes%20en%20num%C3%A9riques%20et%20conservant%20le%20format%20de%20date%20pour%20celles%20qui%20sont%20des%20dates.%3C%2FP%3E%20%0A%20%20%20%3CP%3EMaintenant%2C%20cela%20ne%20fonctionne%20plus%2C%20et%20une%20fen%C3%AAtre%20d'alerte%20arr%C3%AAte%20l'ex%C3%A9cution.%3C%2FP%3E%20%0A%20%20%20%3CP%3EJ'ai%20regard%C3%A9%20dans%20la%20communaut%C3%A9%2C%20j'ai%20essay%C3%A9%20une%20m%C3%A9thode%20sugg%C3%A9r%C3%A9e%20%3A%3C%2FP%3E%20%0A%20%20%20%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ecollist%20%3D%20dt%20%26lt%3B%26lt%3B%20Get%20Column%20Names(%22String%22)%3B%20%09%09%0A%09%09For%20Each(%7Bcolname%7D%2C%20collist%2C%0A%09%09%09r%20%3D%20Column(dt%2C%20colname)%20%26lt%3B%26lt%3B%20Set%20Data%20Type(%22Numeric%22%2C%20%26lt%3B%26lt%3B%20Fail%20On%20Conversion%20Error%2C%20%26lt%3B%0A%20%20%20%20%20%3CRETURN%20failed%3D%22%22%20rows%3D%22%22%3E%3C%2FRETURN%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%20%20%20%3CCODE%20class%3D%22%20language-jsl%22%3E%20%3CP%3ECe%20n'est%20pas%20bon%20car%20nous%20perdons%20le%20formatage%20des%20dates%2C%20donc%20les%20colonnes%20qui%20devraient%20%C3%AAtre%20des%20dates%20apparaissent%20au%20format%20num%C3%A9rique.%3C%2FP%3E%20%3CP%3EQuelqu'un%20pourrait-il%20sugg%C3%A9rer%20une%20solution%20de%20contournement%20%3F%3C%2FP%3E%3C%2FCODE%3E%0A%20%20%3C%2FLINGO-BODY%3E%0A%20%20%3CCODE%20class%3D%22%20language-jsl%22%3E%0A%20%20%20%3CLINGO-LABS%20id%3D%22lingo-labs-909378%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%20%20%20%20%3CLINGO-LABEL%3EAutomatisation%20et%20scripts%3C%2FLINGO-LABEL%3E%0A%20%20%20%3C%2FLINGO-LABS%3E%3C%2FCODE%3E%0A%20%0A%20%0A%20%20%3CLINGO-SUB%20id%3D%22lingo-sub-909408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%26nbsp%3B%3A%20Probl%C3%A8me%20d'importation%20de%20donn%C3%A9es%20%C3%A0%20partir%20d'un%20fichier%20texte%3C%2FLINGO-SUB%3E%0A%20%20%3CLINGO-BODY%20id%3D%22lingo-body-909408%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%20%20%20%3CP%3EQu%E2%80%99est-ce%20qui%20a%20chang%C3%A9%20et%20qui%20a%20emp%C3%AAch%C3%A9%20le%20processus%20de%20fonctionner%20%3F%3C%2FP%3E%20%0A%20%20%20%3CP%3EQuelle%20version%20de%20JMP%20utilisez-vous%20%3F%3C%2FP%3E%20%0A%20%20%20%3CP%3EQuel%20syst%C3%A8me%20d'exploitation%20%3F%3C%2FP%3E%20%0A%20%20%20%3CP%3EPouvez-vous%20fournir%20un%20%C3%A9chantillon%20du%20fichier%20texte%20que%20vous%20lisez%20et%20du%20JSL%20que%20vous%20utilisez%20pour%20le%20faire%20%3F%3C%2FP%3E%0A%20%20%3C%2FLINGO-BODY%3E%0A%20%0A%20%0A%20%20%3CLINGO-SUB%20id%3D%22lingo-sub-909954%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%26nbsp%3B%3A%20Probl%C3%A8me%20d'importation%20de%20donn%C3%A9es%20%C3%A0%20partir%20d'un%20fichier%20texte%3C%2FLINGO-SUB%3E%0A%20%20%3CLINGO-BODY%20id%3D%22lingo-body-909954%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%20%20%20%3CPRE%3EI'm%20using%20JMP%20PRO%20ver%2018.0.0%20(JMP%20normal%20show%20the%20same%20behavior).%3CBR%20%2F%3EOperating%20system%20%3A%20Windows%2010%20Enterprise%3CBR%20%2F%3EWhat%20I%20changed%20is%20the%20instruction%20open(%22C%3A%5CTEMP%5Cjmp_conversion.csv%22%2C%20columns(LOT_ID%3Dcharacter)%2C%20scan%20whole%20file(1))%3B%3CBR%20%2F%3Ewhere%20I%20added%20the%20clause%20columns(LOT_ID%3Dcharacter).%20Without%20this%20change%20it%20works%20(but%20in%20some%20specific%20case%20the%20lot_id%20is%20converted%20numeric%20in%20scientific%20notation%3A%20the%20reason%20for%20the%20change).%3CBR%20%2F%3E%3CBR%20%2F%3EConsider%20that%20if%20you%20run%20just%20the%20following%20script%20you%20do%20not%20receive%20the%20blocking%20alert%20but%20a%20message%20in%20the%20log.%20(I%20don't%20know%20why)%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CCODE%20class%3D%22%20language-jsl%22%3Enumeric_conversion%20%3D%20function(%7Bdt%7D%2C%7BDefault%20Local%7D%2C%0A%09n%3D%20dt%20%26lt%3B%26lt%3B%20get%20name()%3B%0A%09try(delete%20file(%22C%3A%5CTEMP%5Cjmp_conversion.csv%22))%3B%0A%09dt%20%26lt%3B%26lt%3B%20save%20as(%22C%3A%5CTEMP%5Cjmp_conversion.csv%22)%3B%0A%09close(dt%2Cnosave)%3B%0A%09try(%0A%09dt%3D%20open(%22C%3A%5CTEMP%5Cjmp_conversion.csv%22%2C%20columns(LOT_ID%3Dcharacter)%2C%20scan%20whole%20file(1))%3B%0A%09)%3B%0A%09dt%20%26lt%3B%26lt%3B%20set%20name(n)%3B%0A%09return(dt)%3B%0A)%3B%0Adt%3D%20data%20table(%22ExtractedData%22)%3B%0A%0Adt%20%3D%20dt%20%26lt%3B%26lt%3B%20split(%0A%09split(%20%3AVALUE%20)%2C%0A%09split%20by(%20%3APARAM%20)%2C%0A%09group(%20%3ALOT_ID%2C%20%3AWAFER_NO%20)%2C%0A%09remaining%20Columns(%20Keep%20All%20)%2C%0A)%3B%0A%0Adt%20%3D%20numeric_conversion(dt)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%20%20%3C%2FLINGO-BODY%3E%0A%20%0A%20%0A%20%20%3CLINGO-SUB%20id%3D%22lingo-sub-910426%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Probl%C3%A8me%20d'importation%20de%20donn%C3%A9es%20%C3%A0%20partir%20d'un%20fichier%20texte%3C%2FLINGO-SUB%3E%0A%20%20%3CLINGO-BODY%20id%3D%22lingo-body-910426%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%0A%20%20%20%3CP%3ELe%20script%20fonctionne%20parfaitement%20et%20JMP%20indique%20bien%20la%20raison%20du%20message%20de%20journalisation.%3C%2FP%3E%20%0A%20%20%20%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EInvalid%20data%20encountered%20while%20importing%20the%20column%20Reactor.%0A%0A25%20values%20were%20set%20to%20missing.%0ATry%20importing%20the%20data%20again%2C%20but%20explicitly%20set%20the%20Data%20Type%20of%20those%20columns%20to%20Character.%3C%2FCODE%3E%3C%2FPRE%3E%20%0A%20%20%20%3CP%3ECela%20est%20d%C3%BB%20aux%20valeurs%20de%20caract%C3%A8res%20manquantes%20dans%20la%20colonne%20R%C3%A9acteur.%20Pour%20%C3%A9viter%20cela%2C%20vous%20pouvez%20utiliser%20la%20fonction%20Open%20avec%20Log%20Capture().%3C%2FP%3E%20%0A%20%20%20%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Anumeric_conversion%20%3D%20Function(%7Bdt_split%7D%2C%20%7BDefault%20Local%7D%2C%0A%09n%20%3D%20dt_split%20%26lt%3B%26lt%3B%20get%20name()%3B%0A%09Try(Delete%20File(%22C%3A%5CTEMP%5Cjmp_conversion.csv%22))%3B%0A%09dt_split%20%26lt%3B%26lt%3B%20Save%20As(%22C%3A%5CTEMP%5Cjmp_conversion.csv%22)%3B%0A%09Close(dt_split%2C%20nosave)%3B%0A%09Log%20Capture(dt_split%20%3D%20Open(%22C%3A%5CTEMP%5Cjmp_conversion.csv%22%2C%20columns(LOT_ID%20%3D%20character)%2C%20scan%20whole%20file(1)))%3B%0A%09dt_split%20%26lt%3B%26lt%3B%20set%20name(n)%3B%0A%09Return(dt_split)%3B%0A)%3B%0A%0Adt%20%3D%20Open(%22%24DOWNLOADS%2FExtractedData.jmp%22)%3B%0A%0Adt_split%20%3D%20dt%20%26lt%3B%26lt%3B%20split(split(%3AVALUE)%2C%20split%20by(%3APARAM)%2C%20group(%3ALOT_ID%2C%20%3AWAFER_NO)%2C%20remaining%20Columns(Keep%20All)%2C%20Output%20table(%22ExtractedData%20Split%22))%3B%0AClose(dt%2C%20no%20save)%3B%0A%0Adt_split%20%3D%20numeric_conversion(dt_split)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%20%20%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
antonio-domenic
Level III

Importing data from text file issue

We are having problems with data import from text file. Now, we have error message for some columns ("Invalid data encountered while importing column... Try importing the data again, but explicitly set the Data Type of those column to Character").

To better clarify, we have JMP scrip that is used to extract bunch of data from a database. After extracting, the data are organized with parameter in columns and rows for each instance of data. These parameters are all categorical, but there are many numerical (and many are formatted as Date). Some years ago, we asked help to improve the performance (time) to convert all columns to the appropriate data type (using Jmp script took a lot of time because of thousands of columns).

Jim Nelson suggested to save the table as text file and then open again. This worked fine, improving the performances excellently, converting in numeric all columns and maintaining the date format for those that are dates.

Now, this does not work anymore, and a window alert stop the execution.

I looked into community, i tried one suggested method:

collist = dt << Get Column Names("String"); 		
		For Each({colname}, collist,
			r = Column(dt, colname) << Set Data Type("Numeric", << Fail On Conversion Error, <<Return Failed Rows);
			If(N Items(r) == 0,
				Column(dt, colname) << Set Modeling Type("Continuous");
			);
		);

This is not good because of we lose Date formatting, so columns that should be dates appear in numeric format.

Could anyone suggest a workaround?

3 REPLIES 3
txnelson
Super User

Re: Importing data from text file issue

What changed that stopped the process from working?

What version of JMP are you using?

What operating system?

Can you provide a sample of the text file you are reading in, and the JSL you are using to do that?

Jim
antonio-domenic
Level III

Re: Importing data from text file issue

I'm using JMP PRO ver 18.0.0 (JMP normal show the same behavior).
Operating system : Windows 10 Enterprise
What I changed is the instruction open("C:\TEMP\jmp_conversion.csv", columns(LOT_ID=character), scan whole file(1));
where I added the clause columns(LOT_ID=character). Without this change it works (but in some specific case the lot_id is converted numeric in scientific notation: the reason for the change).

Consider that if you run just the following script you do not receive the blocking alert but a message in the log. (I don't know why)

numeric_conversion = function({dt},{Default Local}, n= dt << get name(); try(delete file("C:\TEMP\jmp_conversion.csv")); dt << save as("C:\TEMP\jmp_conversion.csv"); close(dt,nosave); try( dt= open("C:\TEMP\jmp_conversion.csv", columns(LOT_ID=character), scan whole file(1)); ); dt << set name(n); return(dt); ); dt= data table("ExtractedData"); dt = dt << split( split( :VALUE ), split by( :PARAM ), group( :LOT_ID, :WAFER_NO ), remaining Columns( Keep All ), ); dt = numeric_conversion(dt);
jthi
Super User

Re: Importing data from text file issue

The script does work just fine and JMP does tell you the reason for the log message

Invalid data encountered while importing the column Reactor.

25 values were set to missing.
Try importing the data again, but explicitly set the Data Type of those columns to Character.

And that is due to the MISSING character values in Reactor column. If you wish to avoid that, you can wrap Open with Log Capture()

Names Default To Here(1);

numeric_conversion = Function({dt_split}, {Default Local},
	n = dt_split << get name();
	Try(Delete File("C:\TEMP\jmp_conversion.csv"));
	dt_split << Save As("C:\TEMP\jmp_conversion.csv");
	Close(dt_split, nosave);
	Log Capture(dt_split = Open("C:\TEMP\jmp_conversion.csv", columns(LOT_ID = character), scan whole file(1)));
	dt_split << set name(n);
	Return(dt_split);
);

dt = Open("$DOWNLOADS/ExtractedData.jmp");

dt_split = dt << split(split(:VALUE), split by(:PARAM), group(:LOT_ID, :WAFER_NO), remaining Columns(Keep All), Output table("ExtractedData Split"));
Close(dt, no save);

dt_split = numeric_conversion(dt_split);
-Jarmo

Recommended Articles