MathGroup Archive 2007

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

Search the Archive

Re: checking, if a file exists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84403] Re: checking, if a file exists
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Fri, 21 Dec 2007 03:25:31 -0500 (EST)
  • References: <fkeo2q$2fc$1@smc.vnet.net>

You want to use === rather than ==.

Hope this helps...

--David


On Dec 20, 4:50=A0pm, vejra... at icpf.cas.cz wrote:
> Hello,
>
> I am new to Mathematica & I have the following problem: I need to
> 1. check, if a file ("data.dat") with some computationally intensive
> results exists
> 2. if yes, read the file
> 3. if no, do the calculation
>
> I have written (in Mathematica 6) the following:
>
> =A0 fileName = "...some path ... \\data.dat";
> =A0 data = If[FileType[fileName] == File, Import[fileName],
> calculate[0]]
>
> It reads correctly the data if the file exists. But if the file does
> not exists, it returns
>
> =A0 If[None == File, Import[fileName], calculate[0]]
>
> Evidently, the problem is, that
>
> =A0 FileType[fileName] == File
>
> returns correctly True if the file exists, but it does not return
> False when the file is missing -- it returns only None == File.
>
> How to do that?
>
> Thank you.
>
> Jiri



  • Prev by Date: Re: Re: pattern
  • Next by Date: Re: Problem with Out keeping the camera view direction
  • Previous by thread: checking, if a file exists
  • Next by thread: Re: checking, if a file exists