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?
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.
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
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.
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.
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>
Copy link to clipboard
Copied
that's what i was looking for, thanks for your help.