Re: access spreadsheet data

Discussion in 'Python' started by Terry Reedy, Nov 15, 2012.

  1. Terry Reedy

    Terry Reedy Guest

    On 11/14/2012 1:35 AM, Amit Agrawal wrote:
    > my problem is, i want to access data in spreadsheet to python code manualy
    > My data is
    >
    > 1/1982 8:00:000
    > 1/2/1982 8:00:000
    > 1/3/1982 8:00:000
    > 1/4/1982 8:00:000
    > 1/5/1982 8:00:000.7885
    > 1/6/1982 8:00:000
    > 1/7/1982 8:00:000
    > 1/8/1982 8:00:001.6127


    You used tabs, which get deleted by some mail/news readers. Anyway, here
    is a start:

    data='''\
    1/1982 8:00:00 0
    1/5/1982 8:00:00 0.7885
    1/19/1982 8:00:00 0
    1/20/1982 8:00:00 0'''

    lines = data.split('\n')
    # up to here, only for example

    for line in lines:
    fields = line.split()
    print('date {}: time {}: value {}'.format(fields[0], fields[1],
    fields[2]))

    >>>

    date 1/1982: time 8:00:00: value 0
    date 1/5/1982: time 8:00:00: value 0.7885
    date 1/19/1982: time 8:00:00: value 0
    date 1/20/1982: time 8:00:00: value 0

    For real usage assume data are in data.txt in current directory. Then
    start with

    with open('data.txt') as lines:
    for line in lines....

    --
    Terry Jan Reedy
    Terry Reedy, Nov 15, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Twomey
    Replies:
    1
    Views:
    12,581
    Roger Twomey
    Apr 27, 2004
  2. Roberto Lopes
    Replies:
    1
    Views:
    2,168
    mahere
    Dec 27, 2007
  3. =?Utf-8?B?d2FzaG9ldGVjaA==?=

    Pulling data from an Excel spreadsheet into either XML or Dataset

    =?Utf-8?B?d2FzaG9ldGVjaA==?=, Sep 21, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    5,804
    vsurana
    Jul 7, 2008
  4. Ross
    Replies:
    11
    Views:
    634
    Toby Inkster
    Aug 24, 2005
  5. Mark Lawrence

    Re: access spreadsheet data

    Mark Lawrence, Nov 14, 2012, in forum: Python
    Replies:
    0
    Views:
    230
    Mark Lawrence
    Nov 14, 2012
Loading...

Share This Page