Re: A Conditional File Import

*To*: mathgroup at smc.vnet.net*Subject*: [mg66085] Re: A Conditional File Import*From*: albert <awnl at arcor.de>*Date*: Sat, 29 Apr 2006 03:40:20 -0400 (EDT)*References*: <e2ssos$4d2$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi, > I'm wondering if there's a way to do a conditional import of a file > into Mathematica. Say I wrote some code to process a lot of data and > it takes a long time to complete. After it's done, I save my results > by exporting to a text file. When I come back later (months > later...) to pick up where I left off, I'd like to avoid > inadvertently, and because of poor memory, running that long script > again if I already have the results on my hard drive (you would think > that I'd have the sense to check first, but no). > > I was thinking of a script that would work something like this: > > If there is a file X > then > import the file > else > [message] "The darn thing doesn't exist!" > Reprocess the raw data --- [message] "Better make some coffee." > End if then why not convert this to Mathematica syntax and use it? It should work fine, I think. If your question is how to check whether a file exists from within mathematica, look up the function FileType in the help browser. albert