I have multiple zip files that have the same structure — they contain XML files at the root level. All files in each zip file are unique (no duplicates across the zip files). I need to combine all of the XML files from all of the zip files into a single zip file (with the same structure as the original zip files). Suggestions for how to best go about doing this? Thanks.
Share
This is the shortest version I could come up with:
Without testing the alternative, to me this is the best (and probably most obvious too!) solution because – assuming both zip files contains the same amount of data, this method requires the decompression and re-compression of only half of it (1 file).
PS: List comprehension is there just to keep instructions on one line in the console (which speeds debugging up). Good pythonic code would require a proper
forloop, given that the resulting list serves no purpose…HTH!