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 8463539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:28:56+00:00 2026-06-10T14:28:56+00:00

I am trying to create bulk text files based on list. A text file

  • 0

I am trying to create bulk text files based on list. A text file has number of lines/titles and aim is to create text files. Following is how my titles.txt looks like along with non-working code and expected output.

titles = open("C:\\Dropbox\\Python\\titles.txt",'r')  
for lines in titles.readlines():  
       d_path = 'C:\\titles'     
   output = open((d_path.lines.strip())+'.txt','a')  
   output.close()  
titles.close()

titles.txt
Title-A
Title-B
Title-C

new blank files to be created under directory c:\\titles\\
Title-A.txt
Title-B.txt
Title-C.txt

  • 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-10T14:28:57+00:00Added an answer on June 10, 2026 at 2:28 pm

    It’s a little difficult to tell what you’re attempting here, but hopefully this will be helpful:

    import os.path
    with open('titles.txt') as f:
        for line in f:
            newfile = os.path.join('C:\\titles',line.strip()) + '.txt'
            ff = open( newfile, 'a')
            ff.close()
    

    If you want to replace existing files with blank files, you can open your files with mode 'w' instead of 'a'.

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

Sidebar

Related Questions

I am trying to bulk-populate an HBase table quickly from a text file (several
Trying to create a black line in my view to separate text blocks but
I'm trying to create a bulk edit page for an app that I'm working
I'm trying create a query that will output a total number, as well as
I'm trying create an immutable object and initialise it from xml config file in
So, I'm trying to implement a bulk import, i.e. a text area, where people
Hello Everyone Iam trying to bulk insert data from .dat file(unloaded from sybase) in
I am trying to create a bulk loader to upload data into the datastore.
I am trying create a Regex-based replacement for an article to automatically convert embedded
I am trying to add bulk data in database from CSV file. Employee table

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.