0

Imagine I am given two columns: a,b,c,d,e,f and e,f,g,h,i,j (commas indicating a new row in the column)

How could I read in such information from excel and put it in an two separate arrays? I would like to manipulate this info and read it off later. as part of an output.

Nathan
  • 9
  • 1
  • In excel you open VBA and you make your variable equal to the range of the columns you want. See this [question](http://stackoverflow.com/questions/1549191/array-from-range-in-excel-vba) – Forward Ed May 04 '16 at 20:57
  • @ForwardEd I think he want's a python solution. – LismUK May 04 '16 at 21:58
  • @lismUK quite possible, but not stated, and the question was tagged with excel. – Forward Ed May 04 '16 at 22:22
  • @ForwardEd Two of the other tags are python though. – LismUK May 04 '16 at 22:25
  • @LismUK Yes they are, but again the question does not rule out the possibility of VBA within excel. Python is a very educated guess, but not the sole possibility. – Forward Ed May 04 '16 at 22:29

1 Answers1

1

You have a few choices here. If your data is rectangular, starts from A1, etc. you should just use pandas.read_excel:

import pandas as pd
df = pd.read_excel("/path/to/excel/file", sheetname = "My Sheet Name")
print(df["column1"].values)
print(df["column2"].values)

If your data is a little messier, and the read_excel options aren't enough to get your data, then I think your only choice will be to use something a little lower level like the fantastic xlrd module (read the quickstart on the README)

Thtu
  • 1,992
  • 15
  • 21