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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:31:59+00:00 2026-05-30T12:31:59+00:00

I am new to python and I have a question about a piece of

  • 0

I am new to python and I have a question about a piece of python code that creates a cleaned up output file from a model output file. This code was written for a Mac user, but now I want to run it in Windows. But it gives an error message. Could you help me in converting this code so I can use it in Windows? Thanks.

import sys

if len(sys.argv) > 1:
  fileName = sys.argv[1]
else:
  print "selected_um_b.out" #insert file name here
  sys.exit()

f = open(fileName)
counter = 0

fw = open(fileName+".cleaned", 'w')

for line in f:
   line = line.strip()
   counter = counter + 1
   if counter <= 4:
      fw.write(line+"\n");
      continue
   values = line.split("\t")
   if (values[4].strip() == "-99" or values[5].strip() == "0"): continue
   fw.write("\t".join(values)+"\n")

f.close()

Update

The error message is:

Traceback (most recent call last): File
“C:\trial_batch\clean_output.py”, line 7, in sys.exit()
SystemExit

  • 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-30T12:32:00+00:00Added an answer on May 30, 2026 at 12:32 pm

    The program expects a filename on the command line when you execute it. It appears you did not provide one, so the program exited (the sys.exit() call terminates the program).

    How are you trying to use it? If you just want to convert one file, put the file and the Python script into the same directory. Replace lines 3 through 7 with filename = "yourfilename.typ" (do not indent the line); it will read the file (“yourfilename.typ” in my example) and write an output file with ‘cleaned’ in the filename.

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

Sidebar

Related Questions

Hello I am new to python and have a question about the best/pythonic way
To all: I have a question about converting from string to float in python
(I have tagged this question as Python as well since I understand Python code
I have a question about the map function in Python. From what I understand,
(Sorry if it's a trivial question.) I have documents that looks like this (Python
I'm new to Python and have what is probably a very basic question about
I'm new to Python. I have a method that begins: def foo(self, list): length
I'm newish to the python ecosystem, and have a question about module editing. I
This question is a follow-up on a question about Python variable scope . Additional
I have a question about python standard logging mechanism. So if I use logging.config.fileConfig

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.