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.

5
  • In excel you open VBA and you make your variable equal to the range of the columns you want. See this question Commented May 4, 2016 at 20:57
  • @ForwardEd I think he want's a python solution. Commented May 4, 2016 at 21:58
  • @lismUK quite possible, but not stated, and the question was tagged with excel. Commented May 4, 2016 at 22:22
  • @ForwardEd Two of the other tags are python though. Commented May 4, 2016 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. Commented May 4, 2016 at 22:29

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.