I want to import multiple images from url that are within a .txt but I am getting error, is not a valid file, directory, or URL specification

In[1]:= F = Import["/home/hp-pc/Desktop/Fits_3.txt", "Text"]

Out[1]= {"\"https://dr12.sdss.org/sas/dr12/boss/photoObj/frames/301/\

In[2]:= First[Import[#, "FITS"]] & /@ {F}

During evaluation of In[2]:= Import::chtype: First argument "https://dr12.sdss.org/sas/dr12/boss/photoObj/frames/301/2864/1/frame-u-002864-1-0011.fits.bz2"
During evaluation of In[2]:= First::normal: Nonatomic expression expected at position 1 in First[$Failed].

Out[2]= {First[$Failed]}

And I don't really know what is the error


The problem is the way in which the URLs have been imported. First, there's a bunch of extra quotation marks in the road. Second, it appears to be one long string rather than three separate strings (at least the way it's been written above, anyways).



Results of downloading the FITS images.

I end up with two pictures of starry backgrounds and one $Failed. For the third one, either the URL is wrong or they have removed that image because I can't navigate to that page even if I paste the URLs into my browser directly.

Also, it's best practice to begin Mathematica variable names with lowercase letters to avoid conflicts with built-in functions. If you're aware of the built-in functions, it's probably fine, but use C, D, E, I, or N as variable names could cause issues.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.