def get(self): url = 'http://www.corneyandbarrow.com/images/assets/document/CustomerReport.xls' result = urlfetch.fetch(url) xl = readexcel.readexcel(file_contents=result.content) sheetnames = xl.worksheets() new_wines = [] for sheet in sheetnames: for row in xl.getiter(sheet): deferred.defer(handle_xl, row)
def ReadFile(self, file): """ file is an excell file. This method reads the file and return a list of dictionaries (ex: [{'c':0,'s':1,'r':'?','w':1},{...},...]). Each dictionary represents a row of the excell table (= a case for the learning methods) """ xl = readexcel.readexcel(file) sheetnames = xl.worksheets() cases = [] for sheet in sheetnames: for row in xl.getiter(sheet): cases.append(row) return cases
f.close() f = open(sys.argv[0].replace('py', 'json.element')) json_element_template = f.read() f.close() # Load inflation data -- this needs to be renormalized (fd, inflation_fname) = tempfile.mkstemp() os.write(fd, cachedfetch.Fetch('http://www.rba.gov.au/statistics/tables/xls/' 'g02hist.xls')) os.close(fd) inflation = {} current_inflation = 100.0 xls = readexcel.readexcel(inflation_fname) for row in xls.iter_list('Data'): # Rows: # - 0: Month-Year # - 1: All groups # - 2: Tradables # - 3: Tradables excluding food # - 4: Non-tradables # - 5: Food # - 6: Alcohol and tobacco # - 7: Clothing and footwear # - 8: Housing # - 9: Household contents and services # - 10: Health # - 11: Transportation # - 12: Communication
__author__ = 'jdennis' import xmlwitch import os import xlrd import readexcel #open file, read with xlrd #grab 1st row as header as list #for each other row create dictionary with key being corresponding list in #1 (could be 2 dimensional list_ #send dict to function that creates xml & writes to file xl = readexcel.readexcel('/home/tim/Dropbox/PythonXML/Ethiopia_250k_Metadata.xls') sheetnames = xl.worksheets() sheet = sheetnames[0] for row in xl.getiter(sheet): print row write_xmlfile(write_to_xml(row)) def write_to_xml(xls_row_as_dict): '''takes dict representing a row in a geo xls and creates a xml str''' #need to persist the layerID & the callnumber+filename in sqlite db xml = xmlwitch.Builder() with xml.add(allowDups='false'): with xml.doc(): xml.field("450281", name='LayerId') #need to retrieve id & increment xml.field(xls_row_as_dict.CALLNUMBER+xls_row_as_dict.FILENAME, name='Name')#shld be call_number & file name from xls xml.field('UCB', name='WorkspaceName') xml.field('initial collection', name='CollectionId') xml.field('Berkeley', name='Institution')
from selenium.webdriver.support.wait import WebDriverWait import ddt import time import readexcel import os from src.untils.config import Config from src.untils.file_reader import yamlreader import yaml from src.untils.log import Logger from src.test.common.base import browser from src.test.common.base import base BASE_PATH = os.path.dirname(os.path.dirname(__file__)) filepath = os.path.join(BASE_PATH, 'data', 'aa.xlsx') sheetname = "Sheet1" testdata = readexcel.readexcel(filepath, sheetname).data_dirct() mylogger = Logger('TestMyLog').getlog() @ddt.ddt class login(unittest.TestCase): URL = Config().get('D:\\aa\\zhineng\\config\\config.yml', 'URL') @ddt.data(*testdata) def testLogin01(self, data): U"测试百度搜索" self.driver = browser('chrome') base(self.driver).open_url(self.URL) mylogger.info(u"打开浏览器")