Mathematica can import zipped files automatically, but when the content of the zip file it's another zipped file, I just get the list of files in the second zip:

In[317]:= Import["http://www.meff.com/docs/Ficheros/Descarga/dRV/RV120312.zip","*"]

How can I get the content of the last files ?


1 Answer 1


The documentation for the MIME type ZIP does not seem to say much about what you want to do, but luckily the first thing I tried worked!

First, I saved your zip file onto my desktop. Then, I extracted the first level of file names (note that "FileNames" is the default option, so is not explicitly needed)

In[1]:= fn1 = Import["/home/simon/Desktop/RV120312.zip", "FileNames"]
Out[1]= {"today_rv.zip"}

Then the second level of file names

In[2]:= fn2 = Import["/home/simon/Desktop/RV120312.zip", {fn1[[1]], "FileNames"}]

Finally, I extracted, for example, the third file in the inner archive

In[4]:= Import["/home/simon/Desktop/RV120312.zip", {fn1[[1]], fn2[[3]]}]
Out[4]= {{"\"20120312\";\"C2\";\"20\";\"0100\";\"FuturoC IBEX MINI\";1;1", 
  "00;\"EUR\";\"1\";\"FFICSX\""}, {...}, ....}

I think that this final Import defaulted to a CSV import, when you seem to want to separate elements by semicolons (";"), so you should use:

In[5]:= Import["/home/simon/Desktop/RV120312.zip",{fn1[[1]], fn2[[3]], "Table"}, 
           "FieldSeparators"->";"] // Short[#,3]&
Out[5]//Short= {{20120312, C2, 20, 100, FuturoC IBEX MINI, 
                 1, 1,00, EUR, 1, FFICSX}, <<916>>, 
                {20120312, C2, VI, 240, Contado VIVENDI, 
                 1, 1,00, EUR, 2, ESXXXX}}

Note that you could, e.g., use a While loop to automate the digging down to the lowest level of the archive.

  • $\begingroup$ Just to complete the response. I'm importing only the 4th file, but I can't read dates properly: Import["http://www.meff.com/docs/Ficheros/Descarga/dRV/RV120314.zip", \ {"today_rv.zip", "CCONTRSTAT.C2", "Table"}, "FieldSeparators" -> ";", "NumberPoint" -> ",", "Numeric" -> True, "DateStringFormat" -> {"Year", "", "Month", "", "Day"}] Returns the first field as a number but it's a date. Also tried "DateStringFormat" -> {"Year", "Month", "Day"} but doesn't works... $\endgroup$
    – crazzymath
    Commented Mar 15, 2012 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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