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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:33:59+00:00 2026-05-26T11:33:59+00:00

I ran this program on Linux with Python 2.6.2 and it ran fine returning

  • 0

I ran this program on Linux with Python 2.6.2 and it ran fine returning me with decimal values but when I run it on Python 2.7.2 on Windows it does not work and just gives a blank space for a while and then a memory error but I can’t figure out why..I need it to run on Windows its a program to calculate stock equity (ROE). Thanks.

The CSV file needed to run the program is here.
.

import csv

csvname = raw_input("Enter csv name: ")

sbuxfile = csv.reader(open(csvname), delimiter=',', quotechar='|')

# List of Data
row5, row8, row3, row7, avgequity, roe1, roe2 = ([] for i in range(7))

count = 0
# Grab data and numerical values from CSV.
for row in sbuxfile:
  count += 1
  if count == 8:     
     row8 = row
  elif count == 5:   
     row5 = row 
  elif count == 3:   
     row3 = row 
  elif count == 7:   
     row7 = row


a = 1

# Perform calculations for average equity and ROE.
while a < 8 :
   if a == 1:
     avgequity.append(round(float(row8[a]),2))
     roe1.append(float(row5[a]) / float(row8[a]))
     roe2.append((float(row5[a]) / float(row3[a])) * (float(row3[a]) / float(row7[a])) * (float(row7[a]) / float(row8[a]))) 
   else:    
     avgequity.append(round(float((row8[a]),2) + float(row8[a-1]))/2)
     roe1.append(float(row5[a]) / float(row8[a]))
     roe2.append((float(row5[a]) / float(row3[a])) * (float(row3[a]) / float(row7[a])) * (float(row7[a]) / ((float(row8[a]) + float(row8[a-1]))/2)))     
     a+=1 

print "\nAverage equity is " + str(avgequity) + "\n"
print "ROE method 1 is " + str(roe1) + "\n"
print "ROE method 2 is " + str(roe2)
  • 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-26T11:34:00+00:00Added an answer on May 26, 2026 at 11:34 am

    I added a few modifications to your script.
    It works fine on Python 2.7 for Windows.
    Here’s the code:

    import csv
    
    csvname = raw_input("Enter csv name: ")
    
    sbuxfile = csv.reader(open(csvname), delimiter=',', quotechar='|')
    # List of Data
    row5, row8, row3, row7, avgequity, roe1, roe2 = ([] for i in range(7))
    
    count = 0
    # Grab data and numerical values from CSV.
    for row in sbuxfile:
      count += 1
      if count == 8:     
         row8 = row
      elif count == 5:   
         row5 = row 
      elif count == 3:   
         row3 = row 
      elif count == 7:   
         row7 = row
    
    
    a = 1
    
    # Perform calculations for average equity and ROE.
    while a < 8 :
       if a == 1:
         avgequity.append(round(float(row8[a]),2))
         roe1.append(float(row5[a]) / float(row8[a]))
         roe2.append((float(row5[a]) / float(row3[a])) * (float(row3[a]) / float(row7[a])) * (float(row7[a]) / float(row8[a])))
         a+=1   #added this line
       else:    
         avgequity.append(round(float(row8[a]),2) + float(row8[a-1])/2) #rewrote this line as it had an error
         roe1.append(float(row5[a]) / float(row8[a]))
         roe2.append((float(row5[a]) / float(row3[a])) * (float(row3[a]) / float(row7[a])) * (float(row7[a]) / ((float(row8[a]) + float(row8[a-1]))/2)))     
         a+=1 
    
    print "\nAverage equity is " + str(avgequity) + "\n"
    print "ROE method 1 is " + str(roe1) + "\n"
    print "ROE method 2 is " + str(roe2)
    

    The output was :
    Average equity is [2071.11, 3505.7650000000003, 3325.3650000000002, 3273.6400000000003, 3398.375, 4187.76, 5197.549999999999]

    ROE method 1 is [0.12812453225565035, 0.15742791098732495, 0.23651124740462906, 0.2532005689900426, 0.2944854035689894, 0.1283120464917753, 0.2573271287452037]

    ROE method 2 is [0.12812453225565038, 0.17126298080734237, 0.21680660107401206, 0.2613058810726202, 0.29811440335236883, 0.1466466034500227, 0.2814118207249569]

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

Sidebar

Related Questions

Somehow this call to free() is not working. I ran this application on Windows
Since I am writing a program that will eventually run on Windows and Linux
I ran this persons code. It worked as a main but when i put
I ran across this snippet in an internal web site, but I'm having trouble
I just ran this code, and it looks like nice language for me. But
I have a Haskell program that uses Gtk/GtkGLExt and runs fine on Linux (up-to-date
I'm using JNA to manipulate application windows on Linux by sending Xlib messages but
I was trying to run o-profile (a profiling program for linux) and kept getting
When I ran this program: import javax.swing.*; import java.awt.*; public class DrawApplet extends JApplet{
I ran this sample program. const int x = 5; int main(int argc, char**

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.