• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Best way to open zip file, parse contents

New Here ,
Feb 28, 2013 Feb 28, 2013

Copy link to clipboard

Copied

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?

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 02, 2013 Mar 02, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 04, 2013 Mar 04, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 06, 2013 Mar 06, 2013

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 08, 2013 Mar 08, 2013

Copy link to clipboard

Copied

That depends on what type of file it is.  If it's a text file, you can use <cffile action="read">, or <cfloop file="filename">.  You can combine either of those with ReFind() to find something specific you may be looking for.

I've used a combo of the above to find the titles of static HTML pages and read them into my database.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2013 Mar 09, 2013

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 10, 2013 Mar 10, 2013

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation