Skip to main content
Known Participant
February 28, 2013
質問

Best way to open zip file, parse contents

  • February 28, 2013
  • 返信数 2.
  • 1543 ビュー

Hello,

We are working with an affiliate feed that comes in the form of a tab delimited text file that is uploaded to our server as a zip file. While we are well versed on opening and parsing files, i am unsure what the proper technique is for parsing a file that is zipped. Can anyone chime in on the best method for doing so?

    このトピックへの返信は締め切られました。

    返信数 2

    BKBK
    Community Expert
    Community Expert
    March 9, 2013

    ggantzer2 wrote:

    Hello,

    We are working with an affiliate feed that comes in the form of a tab delimited text file that is uploaded to our server as a zip file. While we are well versed on opening and parsing files, i am unsure what the proper technique is for parsing a file that is zipped.

    You may use the cfzip tag to parse a text file within a zip file.  For example, I have the zip file C:\Users\BKBK\Desktop\docs.zip (on Windows system). In the zip file, there is a directory, textDocs, which contains the text file, myList.txt. I can output the contents of the text file as follows:

    <cfzip file="C:\Users\BKBK\Desktop\docs.zip" action="read" variable="fileContent" entrypath="textDocs/myList.txt" />

    <cfoutput>#fileContent#</cfoutput>

    ggantzer2作成者
    Known Participant
    March 10, 2013

    that's what i was looking for, thanks for your help.

    BreakawayPaul
    Inspiring
    March 2, 2013

    I've never used it before, but there is a cfzip tag.  It has read, readbinary, and unzip attributes.  Might be what you need.

    Inspiring
    March 4, 2013

    Unless you need GZip handling, CFZIP works great.  I have apps that use it every day to do what you are talking about.  CF10 also has the ability to "map" a ZIP file as an in-memory filesystem.

    -reed

    ggantzer2作成者
    Known Participant
    March 7, 2013

    i understand the usage of CFZIP, but i am confused as to how i actually do something with a file within the zip itself, in this case open and parse it. How would i access the file inside the zip itself in order to run a cfloop on the contents of the file within the zip to parse it? i'm not sure what i'd actually be looping over.