Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7562665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:27:57+00:00 2026-05-30T13:27:57+00:00

I’m using http://docs.python.org/library/zipfile.html to compress file into a zip. It works well but when

  • 0

I’m using http://docs.python.org/library/zipfile.html to compress file into a zip. It works well but when extracting that file via my ubuntu (not in python, just right clicking file and then ‘Extract here’) file is truncated. My original file has ~167kb, extracted via ubuntu ~164kb (it’s csv file, so I miss few lines from the end of file).

Any suggestions?

Edit:

My code looks as follows:

try:
    fp2 = zipfile.ZipFile(el.replace('.csv', '.zip'), 'w',
            zipfile.ZIP_DEFLATED)
    fp2.testzip()
    fp2.write(el)
finally:
    fp2.close()

Where el is some csv file.

Edit2:
It appears that while writing to a zipfile some data is lost.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:27:59+00:00Added an answer on May 30, 2026 at 1:27 pm

    Some suggestions:

    (1) You call testzip but ignore the returned value. It may mess things up if the archive is empty (as it is in this case). Remove the call to testzip.

    (2) Test the integrity of the created file by another means e.g. (a) linux_zipfile_executable -t your_created_archive.zip (b) short Python script using testzip. Try some other extraction means.

    (3) Ignore the mode='wb' pushers; that is relevant only to files opened with built-in open. As the zipfile docs say, the only permissible modes are r, w, and a. Else: RuntimeError: ZipFile() requires mode "r", "w", or "a". The zipfile code actually does use the b flag when it opens the archive file using built-in open.

    (4) Check carefully that in the flurry of trying to find your problem you are in fact comparing the correct pair of csv files.

    (5) Post the 3 files (input, output, and .zip) on the web somewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.