Skip to main content
Known Participant
Feb 28, 2013 10:12 PM UTC
Question

Best way to open zip file, parse contents

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?

    This topic is closed to new replies. Start a new post to keep the conversation going.

    6 replies

    BKBK
    Community Expert
    Community Expert
    Mar 9, 2013 12:27 PM UTC

    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>

    Translate
    ggantzer2Author
    Known Participant
    Mar 10, 2013 11:11 PM UTC

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

    Translate
    BreakawayPaul
    Inspiring
    Mar 2, 2013 4:54 PM UTC

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

    Translate
    Inspiring
    Mar 4, 2013 3:45 PM UTC

    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

    Translate
    ggantzer2Author
    Known Participant
    Mar 7, 2013 1:45 AM UTC

    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.

    Translate