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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:47:00+00:00 2026-05-24T00:47:00+00:00

I am trying to get input from the user at the command prompt. The

  • 0

I am trying to get input from the user at the command prompt. The program reads in data from a text file in the manner of “cat text.txt | ./thescript.py”

At the point of the script in question, all data has already been read in, processed, and put into a list of lists.

Now I am iterating through that list of lists looking for questionable items. The code basically looks like this:

for invoice in parsedlist:
      if invoice[-1] == 3:
          sys.stderr.write("triple duplicate at " + invoice[2]+' : ' + invoice[3]+"\n")
          sys.stderr.write("continue Y or N \n")
          answer = raw_input("Type your answer here")
          if answer == 'N':
              sys.exit(1)
          else: 
              pass`

This code results in an EOFError. From what I already understand, stdin is the read from cat in this case and since it has already reached EOF that is why raw_input gets EOF here? (I think) The objective is to have the script print a warning to standard error and let me choose whether to ignore the warning and continue or quit entirely. In the end all output goes to std out and will not include any of the error warnings or responses. I have seen examples that use a try/exception but I have not been able to make sense of it in this context. (Eg. Why does the raw_input not wait for input?)

I think I may just be attacking this problem in the wrong way and thus creating a problem that could be better walked around then jumped over. Any help is appreciated as always.

  • 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-24T00:47:01+00:00Added an answer on May 24, 2026 at 12:47 am

    Yes, the problem is that your raw_input() is reading from standard input, which is the output of cat, which is at EOF.

    My suggestion would be to eliminate the cat. It is not necessary; Python is perfectly capable of reading files on its own. Pass the file name on the command line, open it, and read it yourself.

    import sys
    
    for line in open(sys.argv[1]):
        # process line
    

    If you need to handle multiple files, check out the fileinput module; it easily handles reading multiple files as if they were one, which is what cat does for you.

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

Sidebar

Related Questions

I am trying to get text input from the keyboard in Java 6. I
I'm trying to get a date for an event from a user. The input
I'm trying to get some input from a user and use that input in
I'm trying to get input from user and give output until s/he presses 'n'.
I'm trying to get this script to basically read input from a file on
I am trying to get input from the user and need to know a
I'm trying to get all the input elements from a certain form from jQuery
I'm trying to get this C++ code to input a series of numbers from
I'm trying to get console input in my Clojure program, but when it gives
I am trying to get the value of the text in the input fields.

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.