I repeatedly open a certain file type, which needs special import settings to opening correctly.
I would like to be able to write these import settings in a short compact form. For instance:
where "string_that_parses_correctly" is the whole string, that holds the settings' conditions. In my case I use:
"End Of Line( CRLF, CR, LF ),
End Of Field( Tab ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Treat empty columns as numeric( 0 ),
Labels( 1 ),
Column Names Start( 1 ),
Data Starts( 2 ),
Lines To Read( All ),
Year Rule( "20xx")"
I captured these settings from the script generated by opening one of these files.
So is there a way to define a string, for instance as a global variable, that always is set, so that I can use it when opening the file as shown.
I hope it makes sense.
Poul Ravn Sørensen
HI, I am replying to this myself.
My problems boils down the issue of combining strings into a parseable piece of jsl.
I have defined a string that contains the string, that set the special settings for the xls (csv) import. It start out: Import Settings(. . . );
Then I want dynamically to assign the file, that should be opened, like:
xls_fileid = "\\server\folder\filename";
Finally I want to combine these two like this:
But somehow get the double quotation marks mixed up.
Anyone has an example of how this is done?
You can either use \[ ... ]\ to put double quotes into a string.
Or escape them with \!". Here are some examples.
// The following statements yield the same results:
From the log:
Hi again, here is my JMPstart.jsl code, that sets the xls_settings (why I sometimes can't paste text into this window I do not know), :
Here are my attempts to biuld the string the opens the actual Excel file:
But the quotes keep causing errors.
You're missing double quotes around the file reference.
Your command openxls doesn't do anything. You need to add OPEN to it.
One of the nice things about JSL is its interactivity. As you build the string, highlight it and click Run. Check the log window and see what you've created. Keep iterating until you get what you want.
This is possibly what you're trying to do:
xls_settings = "\[
End of line (crlf, cr, lf),
end of field(tab),
use apostrophe as quotation mark(0),
scan whole file(1),
treat empty columns as numeric(0),
column names start(1),
lines to read(all),
openxls = evalinsert("\[open("^xls_fileid^", ^xls_settings^) ]\")