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

The Archive Base Latest Questions

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

I’m new to python and have been trying to figure this out all day.

  • 0

I’m new to python and have been trying to figure this out all day. I have a data file laid out as below,

time    I(R_stkb)

Step Information: Temp=0  (Run: 1/11)

0.000000000000000e+000  0.000000e+000

9.999999960041972e-012  8.924141e-012

1.999999992008394e-011  9.623148e-012

3.999999984016789e-011  6.154220e-012

(Note: No empty line between the each data line.)

I want to plot the data using matplotlib functions, so I’ll need the two separate columns in arrays.

I currently have

def plotdata():

Xvals=[], Yvals=[]
i = open(file,'r')

for line in i:
    Xvals,Yvals = line.split(' ', 1)

print Xvals,Yvals

But obviously its completely wrong. Can anyone give me a simple answer to this, and with an explanation of what exactly the lines mean would be helpful. Cheers.

Edit: The first two lines repeat throughout the file.

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

    This is a job for the * operator on the zip method.

    >>> asdf
    [[1, 2], [3, 4], [5, 6]]
    
    
    >>> zip(*asdf)
    [(1, 3, 5), (2, 4, 6)]
    

    So in the context of your data it might be something like:

    handle = open(file,'r')
    lines = [line.split() for line in handle if line[:4] not in ('time', 'Step')]
    Xvals, Yvals = zip(*lines)
    

    or if your really need to be able to mutate the data afterwards you could just call the list constructor on each tuple:

    Xvals, Yvals = [list(block) for block in zip(*lines)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from

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.