Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Import[] - limited from a pipe?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103996] Re: Import[] - limited from a pipe?
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Thu, 15 Oct 2009 07:15:41 -0400 (EDT)
  • References: <hb3g2j$m04$1@smc.vnet.net>

Jason Ledbetter wrote:
> Folk,
> I'm looking into various methods of importing data into mathematica from a
> piece of perl middleware (that talks to a database). Right now, the perl
> script is outputting CSV that I'm pulling in with Import[....,"CSV"] or
> "List" in some cases.
> 
> In investigating other options (like Get) it seems that there are some
> limitations on Import[] that I don't quite understand.
> 
> As a test, I'm looking at two components:
> 
> 1 - a perl script that outputs "List[1,2,3,4]" (no newlines) and then
> exits.
> 2 - the output from that perl script redirected to a file "foo"
> 
> In the first case:
> 
> In[17]:= Import["!/full/path/test.pl", "Elements"]
> Import::fmtnosup: $Failed is not a supported Import format.
> Out[17]= $Failed
> 
> In the second case:
> 
> In[24]:= Import["/full/path/to/foo", "Elements"]
> Out[24]= {Comments, ExpressionList, Get, HeldExpressions}
> 
> (* changing Elements to Get in the file version results in an appropriate
> List[1,2,3,4,5] being imported *)
> 
> Is this a bug or expected behavior?
> If it is expected, where can I find/generate more information on the
> limitations of Import with a pipe?
> 
> Thanks,
> 
> -jbl
> 
> 
I think the problem is that Import can't deduce the data format from the 
pipe name. The help for Import includes the sentence:

Import["!prog","format"] imports data from a pipe.

I guess this would solve the problem, though I have not tried it.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: - limited from a pipe?
  • Next by Date: Re: ChemicalData[], SMILES, EdgeRules
  • Previous by thread: Re: Import[] - limited from a pipe?
  • Next by thread: Re: Error code: 480David Bailey,http://www.dbaileyconsultancy.co.uk