Subscribe Bookmark RSS Feed

JSL - what am I doing wrong?

adamrowe

Community Trekker

Joined:

Jun 23, 2011

Hi,

I am trying to write a simple script that will open a csv file and then remove selected columns/ rows. I can get the script to open up the table OK but it does nothing after that. Please can you advise where I have gone wrong? Script below:

dt=open(
Pick File(
"Select a *.csv file",
Get Current Directory(),
{"All JMP Files|jmp;jsl;jrn;csv", "All Files|*"}
),
columns(
Name( "Date" ) = Character,
Time = Character,
Counter = Character,
Printed number = Numeric,
System Result = Character,
PiercePosX 1 = Numeric,
PiercePosX 2 = Numeric,
PiercePos X = Numeric,
Column 9 = Numeric,
Column 10 = Numeric,
Column 11 = Numeric,
Column 12 = Numeric,
Column 13 = Numeric,
Column 14 = Numeric,
Column 15 = Numeric,
Column 16 = Numeric,
Column 17 = Numeric,
Column 18 = Numeric,
Column 19 = Numeric,
Column 20 = Numeric,
Column 21 = Numeric,
Column 22 = Numeric,
Column 23 = Numeric,
Column 24 = Numeric,
Column 25 = Numeric,
Column 26 = Numeric,
Column 27 = Numeric,
Column 28 = Numeric,
Column 29 = Numeric,
Column 30 = Numeric,
Column 31 = Numeric,
Column 32 = Numeric,
Column 33 = Numeric,
Column 34 = Numeric,
Column 35 = Numeric,
Column 36 = Numeric,
Column 37 = Numeric,
Column 38 = Numeric,
Column 39 = Numeric,
Column 40 = Numeric,
Column 41 = Numeric,
Column 42 = Numeric,
Column 43 = Numeric,
Column 44 = Numeric,
Column 45 = Numeric,
Column 46 = Numeric,
Column 47 = Numeric,
Column 48 = Numeric,
Column 49 = Numeric,
Column 50 = Numeric,
Column 51 = Numeric,
Column 52 = Numeric,
Column 53 = Numeric,
Column 54 = Numeric,
Column 55 = Numeric,
Column 56 = Numeric
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Comma ),
Strip Quotes( 0 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Labels( 1 ),
Column Names Start( 6 ),
Data Starts(7 ),
Lines To Read( All ),
Year Rule( "10-90" )
),

dt << delete rows( 64 );
dt << delete rows( 63 );
dt << delete rows( 1 );
);

Thanks,

Adam
8 REPLIES
mpb

Super User

Joined:

Jun 23, 2011

Try moving the 3 delete rows lines after the current final semi-colon.

By the way, you can delete multiple rows by supplying the argument to delete rows as a list or matrix:

dt << delete rows({64, 63, 1})

or

dt << delete rows([ 64 63 1])
adamrowe

Community Trekker

Joined:

Jun 23, 2011

Thanks,

Next is possible to get JMP to open multiple .csv files and process them at once? I would have them all in one folder with upto 200 odd csv files (all exact same format).
mpb

Super User

Joined:

Jun 23, 2011

Yes it is possible. Search the forum for "open multiple files" without the quotes. You may find some of the hits helpful.
adamrowe

Community Trekker

Joined:

Jun 23, 2011

Thanks again...another problem.
With the following extract of script:
Set Current Directory(
"xyz"
);
files = Files In Directory(
"xyz"
);
For( i = 1, i <= N Items( files ), i++,

Open(
files,

I in the for statement is only returning a value of 2 (i.e. two files in the directory), when in fact there are eight. The files in directory function recognises eight files correctly.
adamrowe

Community Trekker

Joined:

Jun 23, 2011

Thanks, another problem...
Set Current Directory("xyz");
files = Files In Directory("xyz");
For( i = 1, i (less than or equal to) N Items( files ), i++,
Open(files,...

In the "for" statement, "i" only recognises 2 data files. In fact 8 are present within the directory as correctly identified in files in directory function. Any ideas?

Thanks
mpb

Super User

Joined:

Jun 23, 2011

What do you get in the log if you insert these lines after the second current line:

count = n items(files);
show(count, files);

and omit the rest.
adamrowe

Community Trekker

Joined:

Jun 23, 2011

Seems to be functioning OK.. not sure what I've changed. Many thanks for your help.

On a separate note (as the script evolves), is it possible for JMP to extract data from a single cell in a csv file and copy that down into JMP data table with data (multiple cells) extracted from the csv file, i.e. batch details and operator comments. In the JMP data table the batch details would have to be repeated down the cells...

The csv looks like:
batch: xx (single cell)
Comments: x (single cell)
Data (multiple rows and columns) - already being extracted.
mpb

Super User

Joined:

Jun 23, 2011

Import the columns you need from the csv file into a JMP table. Assuming that table and the other table have a column in common take a look at Tables > Join (by matching column), or Tables > Update.