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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:09:01+00:00 2026-06-08T22:09:01+00:00

Here is my code: if __name__ == ‘__main__’: fid = open (‘200502.txt’) data =

  • 0

Here is my code:

if __name__ == '__main__':
  fid = open ('200502.txt')
  data = fid.readlines()
  data = map (string.strip, data)
  x = []
  y = [] 
  da = []
  for d in data:
    s = d.split()
    x.append(float(s[0])/10000.0)
    y.append(float(s[1])/10000.0)
    da.append(float(s[2]))

When I run it I got:

Traceback (most recent call last):
  File "plot_data.py", line 286, in ?
    x.append(float(s[0])/10000.0)
IndexError: list index out of range

The 200502.txt (840kb) file is like:

1131087 224529 3.923   
1131096 224529 3.958 
1131106 224530 3.897    
1131116 224530 3.917   
1131126 224530 3.847 
(....)
  • 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-08T22:09:03+00:00Added an answer on June 8, 2026 at 10:09 pm

    This is a fragile way to load your data. My guess is it’s breaking on a newline at the end of the file, or something like that. Regardless, you should load your file with numpy.loadtxt instead (or csv module if you don’t have access to numpy).

    To get you started on that:

    >>> import numpy
    >>> data = numpy.loadtxt('/tmp/200502.txt')
    >>> xs = data.T[0]/10000.
    >>> ys = data.T[1]/10000.
    >>> da = data.T[2]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the code: string name = myName; int id = (int)_myDB.ThingTable.Where(thing => thing.ThingName ==
Here is my code: class Soldier { public: Soldier(const string &name, const Gun &gun);
I have a small Problem using reg. expressions with scanner here's the code: String
$.getJSON( test.php, function(data){ ... code should be here? } ) data contains this code:
Here is my table and data of these tables Table name: Code CID Code
Here i am having a unordered list displaying two columns code and name .I
I have this code here: var Person = (function() { var name; var PersonConstructor
I have created one UIImageView Here's code capView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kARROW_CAP_NAME]]; capView.frame
here is my plugin activation code $classified_category_name = 'classified'; $credit_table_name = 'credits'; $credit_table_version =
Here's the code: <?php class Order extends Zend_Db_Table_Abstract { protected $_name = 'orders'; protected

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.