\n","author":{"@type":"Person","name":"OrbitDuster"},"upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"
If you want, you can also read only the first column with pd.read_excel
. I think this might be a bit more efficient than reading the whole file.
As I see it, you don't want repeated orders, that's why you can use set()
import pandas as pd\n\ndf = pd.read_excel("file.xlsx", index_col=None, na_values=['NA'], usecols="A")\n# get the first column of df\nOrder_List = set(df.iloc[:, 0])\n\nprint(Order_List)\n
\n","author":{"@type":"Person","name":"user11718531"},"upvoteCount":3}}}Reputation: 111
I have a program that works perfectly in placing orders for my company for a list that I define. I want to know how I could pull the list from an excel file instead of manually typing them out each time?
code below:
Order_List = ['0043777770','003897270','0048377270']
for eachId in Order_List:
#go to website
#find and select item
# enter quantiy
#check out
#save invoice
But instead of me manually entering each order# into the order_list can I pull it from an excel file or read through each order # in the excel? the excel file looks something like this and I need the first column data A2-A20 etc.
Upvotes: 1
Views: 2076
Reputation: 1
You can use pandas.
With for.
Example.
import pandas as pd
df = pd.read_excel('namexlsx.xlsx')
List_order = []
for i in namexlsx.index:
order = df.at[i, 'Order number']
List_order.append(order)
Upvotes: 0
Reputation:
If you want, you can also read only the first column with pd.read_excel
. I think this might be a bit more efficient than reading the whole file.
As I see it, you don't want repeated orders, that's why you can use set()
import pandas as pd
df = pd.read_excel("file.xlsx", index_col=None, na_values=['NA'], usecols="A")
# get the first column of df
Order_List = set(df.iloc[:, 0])
print(Order_List)
Upvotes: 3