473,378 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to input data from an excel file into a list

4
Hi,

I have an excel file which contains 3 columns and lots of rows. How do I put these data into a list in Python? (like [(1,2,3),(4,5,6),...])
Jan 17 '14 #1
1 1750
bvdet
2,851 Expert Mod 2GB
Here's an example:
Expand|Select|Wrap|Line Numbers
  1. import xlrd
  2. from PIL import Image
  3.  
  4. height = 100
  5.  
  6. wb = xlrd.open_workbook("rgb_values.xlsx")
  7. sheet1 = wb.sheet_by_index(0)
  8. data = []
  9. for i in range(0, sheet1.nrows):
  10.     for line in range(height):
  11.         data.append(tuple(int(j) for j in sheet1.row_values(i)))
  12.  
  13. im = Image.new("RGB", (sheet1.nrows, height))
  14. im.putdata(data)
  15. im.save("pix1.png")
Jan 17 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: QQ | last post by:
I am trying to read data from Excel files I use the following codes, however, it didn't work Can anyone tell me what the format excel files have, what I should do to read it from C? Thanks a...
1
by: Grey | last post by:
I have created a asp.net form for user to input data. After input the data, user need to click a button to export the input data to excel for data analysis with excel pivot table function. is it...
3
by: RJN | last post by:
Hi I've a template excel file which has all the calculations defined. There are certain input values to be entered which gives a lot of output to the user. I don't want to expose the excel sheet...
8
by: Radu | last post by:
Hi, I have the following problem: I open a recordset based on excel/csv files, but then I need to filter (in code) in order to extract only data pertaining to a specific person. This code is...
1
by: phys00 | last post by:
I have a file counted 10 columns (every columns has 1000 measurements) of data and I need to select only 4 columns only. How I can do this with C programming. help please!!
8
by: cgrider | last post by:
I have an access databae that I am creating to import data from the end user from an excel file. And from that generate a report for him to send to a customer. The issue that I am having the report...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
15
by: patf | last post by:
Hi - experienced programmer but this is my first Python program. This URL will retrieve an excel spreadsheet containing (that day's) msci stock index returns. ...
13
by: mixahlel | last post by:
Hi, i am using APACHE POI to read the data from excel files. I would like to store them in lists (like list in c) the result because afterwards I will try to store them in mysql database. What i...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.