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

  • SEARCH
  • Home
  • 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 8901211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:17:27+00:00 2026-06-15T01:17:27+00:00

I am doing some file processing and for generating the file i need to

  • 0

I am doing some file processing and for generating the file i need to generate some temporary file from existing data and then use that file as input to my function.

But i am confused where should i save that file and then delete it.

Is there any temp location where files automatically gets deleted after user session

  • 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-06-15T01:17:28+00:00Added an answer on June 15, 2026 at 1:17 am

    Python has the tempfile module for exactly this purpose. You do not need to worry about the location/deletion of the file, it works on all supported platforms.

    There are three types of temporary files:

    • tempfile.TemporaryFile – just basic temporary file,
    • tempfile.NamedTemporaryFile – "This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved from the name attribute of the file object.",
    • tempfile.SpooledTemporaryFile – "This function operates exactly as TemporaryFile() does, except that data is spooled in memory until the file size exceeds max_size, or until the file’s fileno() method is called, at which point the contents are written to disk and operation proceeds as with TemporaryFile().",

    EDIT: The example usage you asked for could look like this:

    >>> with TemporaryFile() as f:
            f.write('abcdefg')
            f.seek(0)  # go back to the beginning of the file
            print(f.read())
    
        
    abcdefg
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a python script that will be doing some processing on text
So, I'm doing some image processing in MATLAB, and attempting to save a file
I am processing a file with awk and need to skip some lines. The
Hello Stack Overflow community, I am doing multistep processing on some data I am
I'm doing some Wave file handling and have them read from disk into an
I am doing some real-time video processing with openCV. So much in fact that
I am creating a webpage with javascript that is doing some processing and building
In my program, I am basically reading in a file, doing some processing to
I have some tagged data that I am processing using lxml. When I open
In my mxml file, I'm doing some calculations in the script tag, and binding

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.