Zotto
Zotto

Reputation: 73

Use Python script to extract data from excel sheet and input into website

Hey I am python scripting novice, I was wondering if someone could help me understand how I could python, or any convenient scripting language, to cherry pick specific data values (just a few arbitrary columns on the excel sheet), and take the data and input into a web browser like chrome. Just a general idea of how this should function would be extremely helpful, and also if there is an API available that would be great to know.

Any advice is appreciated. Thanks.

Upvotes: 0

Views: 34722

Answers (1)

BSL-5
BSL-5

Reputation: 714

Okay. Lets get started.

Getting values out of an excel document

This page is a great place to start as far as reading excel values goes.

Directly from the site:

import pandas as pd

table = pd.read_excel('sales.xlsx',
                  sheetname = 'Month 1',
                  header = 0,
                  index_col = 0,
                  parse_cols = "A, C, G",
                  convert_float = True)

print(table)

Inputting values into browser

Inputting values into the browser can be done quite easily through Selenium which is a python library for controlling browsers via code.

Also directly from the site:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

How to start your project

Now that you have the building blocks, you can put them together.

Example steps:

  1. Open file, open browser and other initialization stuff you need to do.
  2. Read values from excel document
  3. Send values to browser
  4. Repeat steps 2 & 3 forever

Upvotes: 8

Related Questions