extract information from excel into python 2d array -


I have a date, time and temporarily Excel Sheet that looks like this:

< Img Src = "https://i.stack.imgur.com/RioSe.png" alt = "Enter the image details here">

Using the python, I will remove this information in python arrays Want to

The array will be found in position 0, and then store the templates in the following situations and look like this:

  temparray [0] = [20130102,34.75, 34.66, 34.6,34.6, ...., 34.86] temparray [1] = [20130103,34.65,34.65,34.73,34.81, ...., 34.64]  

Here are my efforts But it is useless:

from xlrd import * print to open_workbook ('temp.xlsx') wb = open_workbook ('temp.xlsx') in wb.sheets (): range in range (s) .nrows): for values ​​[=] for range (s.ncols): values.append (s.cell (line, color) .value) print (value [0]) print ("% .2 F "% value [1]) print '' ''

I used xlrd, but I'm open to using anything. Thanks for your help.

The problem I understand with your question is that you want to be the list of output lists For, and you are not getting any such thing.

And that is because there is nothing in your code that tries to get such a thing for each line, you create a list, that Print the first value of the list, print the second value of that list, and then forget the list.

A list of one of the list of those lists, which you have to do, is that which you are doing to add each column value to row lists:

  temparray = [] for row in range (s.nrows)): value = [] for calls in range (s.ncols): values.append (s.cell (line, color) .value) Temparray.append (value)  

From your comment, it seems that you want in fact , not only this, but with the day -with-therm Issues are also grouped, and add only the second column instead of days each value. All that is described in your question is not in all. In that case, you should not loop at all on the columns. Do you want something like this: date = [] current_day, current_date = [], none for the row in range (s.nrows): date = s.cell (line, 0) If the date! = Current_data: current_day, current_data = [], datedays.appment (current_day) current_dayday.append (s. Col (line, 2)) This code assumes that the dates always sort order Because they are in your input screenshots.

I'll probably structure it differently, I'm building a lineariter to pass, but I wanted to keep it as a newbie, and closer to your original code, possible.

In addition, I suspect that in fact you do not want to:

  [[date1, temp1a, temp1b, temp1c], [date2, temp2a, temp2b] ]  

... but something like this:

  {date1: [temp1a, temp1b, temp1c], dated 2: [temp1a, temp1b, temp1c] }  

But without knowing the intention of doing with this information, I can not tell you how best it will store. / P>


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -