Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: access spreadsheet data

Reply
Thread Tools

Re: access spreadsheet data

 
 
Terry Reedy
Guest
Posts: n/a
 
      11-15-2012
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: access spreadsheet data Mark Lawrence Python 0 11-14-2012 06:58 AM
Pulling data from an Excel spreadsheet into either XML or Dataset =?Utf-8?B?d2FzaG9ldGVjaA==?= ASP .Net 5 07-07-2008 02:13 PM
Exporting Repeater data to an Excel Spreadsheet Roberto Lopes ASP .Net 1 12-27-2007 03:21 PM
seeking suggestion for posting spreadsheet data on web Ross HTML 11 08-24-2005 07:28 AM
System.Data.OleDb.OleDbException: Could not find installable ISAM : Read Excel Spreadsheet in web-form Roger Twomey ASP .Net 1 04-27-2004 09:12 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57