Subscribe Bookmark RSS Feed

open a file from an ftp site

I'm having a little trouble opening a file from an ftp site. Can anyone help? I thought treating it like a regular http site would work, but it does not. I'm just using the regular open command, like:

Open ( "ftp://ftp.nasdaqtrader.com/symboldirectory/nasdaqlisted.txt");

But that doesn't work. I've tried using delimiters, stripquotes, and all sorts of stuff. I can save it to my hard drive and import just fine that way. But when I try to nab it from the ftp site it doesn't work. Any ideas? Socket connection maybe? Datafeed()? Or does anyone know if it's possible to access the File>Internet Open feature found in the File menu bar?

Thanks in advance for posting.

Message was edited by: shwaZmoto
4 REPLIES
mpb

Super User

Joined:

Jun 23, 2011

Using 8.0.2 on WinXP sp2, the only way I have so far been able to open that file inside JMP is to manually do an Internet Open, specify the file as you have done but without the quotes, and choose Edit HTML or a Text page. When prompted for username and password I press Enter and then the file opens as a text file in the script editor. I don't know how to invoke Internet Open in a script...

Ok, I take that back. This also works: In scripting I execute the line Open() . In the resulting open dialog I specify the file as you did but without the quotes and I choose one of the 4 import methods. Then I click ok. JMP imports the file. When I check the Source script embedded in the imported file I see that the code does not directly reference the ftp site. It references a temporary local copy.
Thanks for the response mpb. It's good to hear other's ideas. So what you said got me thinking. Maybe instead of using JMP's Open() function, I could use window's kernel32.dll CreateFile function by marshalling the dll. Something like this, although this doesn't work and I'm not certain as to why:

If( Host is( Windows ) & Or( JMP Version() == " 8.0.1", JMP Version() == " 8.0.2", JMP Version() == " 9.0.0" ),

kernel32 = Load DLL( "kernel32" );

/*
http://msdn.microsoft.com/en-us/library/aa363858%28v=VS.85%29.aspx
*/

kernel32 << DeclareFunction(
"CreateFileA",
Convention( STDCALL ),
Alias( "CreateFile" ),
Arg( AnsiString, "lpFileName" ),
Arg( AnsiString, "dwDesiredAccess" ),
Arg( AnsiString, "dwShareMode" ),
Arg( UInt32, "dwCreationDisposition" ),
Arg( AnsiString, "dwFlagsAndAttributes" ),
Returns( AnsiString )
);

CreateFileA( "ftp://ftp.nasdaqtrader.com/symboldirectory/nasdaqlisted.txt", "GENERIC_READ", "FILE_SHARE_READ", 2, "FILE_ATTRIBUTE_NORMAL" );
kernel32 << ShowFunctions();
kernel32 << UnloadDll();
)

It's still very strange to me that JMP lacks scripting support for FTP servers. There's also a ReadFile function in kernel32.dll that could be used to create an I/O stream, but I'm guessing it's probably much the same as JMP's socket connections.

I'd much rather be able to script the built-in menu command "File:Open Connection". It seems to do everything I want for I/O purposes.

Message was edited by: shwaZmoto
mattf

Community Trekker

Joined:

Jun 23, 2011

Hi:

/File, Internet Open
, hit enter when prompted for username and password produces for me a data table with the associated script:

<-
Open(
"/0540FBF8/nasdaqlisted.txt",
columns(
Name(
"Symbol|Security Name|Market Category|Test Issue|Financial Status|Round Lot Size"
) = Character,
Column 2 = Character,
Column 3 = Character,
Column 4 = Character,
Column 5 = Character,
Column 6 = Character,
Column 7 = Character
),
Import Settings(
End Of Line( CRLF, CR, LF ),
End Of Field( Tab, Comma ),
Strip Quotes( 1 ),
Use Apostrophe as Quotation Mark( 0 ),
Scan Whole File( 1 ),
Labels( 1 ),
Column Names Start( 1 ),
Data Starts( 2 ),
Lines To Read( All ),
Year Rule( "10-90" )
)
);
->


Best regards,
-Matt
Thanks Matt!

I forgot to check "source > edit" on the data table after opening it manually from the internet.