openpyxl

how to fill excel file from selenium scraping in loop with python

浪尽此生 提交于 2020-12-15 07:02:31
问题 i am trying to scrap a website than contain many pages, with selenium i open each time a page in second 'TAB' and launch my function to get the data. after that i close the tab and open the next tab and continue extraction until the last page. my problem is when i save my data in the excel file, i found that it save just the last information extract from the last page(tab). can you help me to find my error ? def scrap_client_infos(linksss): tds=[] # tds is the list that contain the data

Highlight dataframe cells based on multiple conditions in Python

别等时光非礼了梦想. 提交于 2020-12-13 05:40:05
问题 Given a small dataset as follows: id room area situation 0 1 A-102 world under construction 1 2 NaN 24 under construction 2 3 B309 NaN NaN 3 4 C·102 25 under decoration 4 5 E_1089 hello under decoration 5 6 27 NaN under plan 6 7 27 NaN NaN Thanks to the code from @jezrael at this link, I'm able to get the result I needed: a = np.where(df.room.str.match('^[a-zA-Z\d\-]*$', na = False), None, 'incorrect room name') b = np.where(df.area.str.contains('^\d+$', na = True), None, 'area is not a

Writing dataframes to multiple sheets in existing Excel file. Get 'We Found Problem with some content in X.xlsx' when opening excel file

霸气de小男生 提交于 2020-12-13 04:25:38
问题 I'm creating a few dfs based on existing excel files. I'm then writing each of those dfs to their own separate sheet in a different (existing excel) file. Script executes fine, but when I open the excel file the dfs were written to I get the following error msg: "We found a problem with some content in 'X.xlsx'... I tried this not using openpyxl as several answers on similar posts indicated you didn't have to use openpyxl; however, pandas docs indicate you need to use openpyxl if writing to

Writing dataframes to multiple sheets in existing Excel file. Get 'We Found Problem with some content in X.xlsx' when opening excel file

谁说我不能喝 提交于 2020-12-13 04:25:13
问题 I'm creating a few dfs based on existing excel files. I'm then writing each of those dfs to their own separate sheet in a different (existing excel) file. Script executes fine, but when I open the excel file the dfs were written to I get the following error msg: "We found a problem with some content in 'X.xlsx'... I tried this not using openpyxl as several answers on similar posts indicated you didn't have to use openpyxl; however, pandas docs indicate you need to use openpyxl if writing to

Processing large XLSX file in python

别说谁变了你拦得住时间么 提交于 2020-12-10 08:57:37
问题 I have a large xlsx Excel file (56mb, 550k rows) from which I tried to read the first 10 rows. I tried using xlrd , openpyxl , and pyexcel-xlsx , but they always take more than 35 mins because it loads the whole file in memory. I unzipped the Excel file and found out that the xml which contains the data I need is 800mb unzipped. When you load the same file in Excel it takes 30 seconds. I'm wondering why it takes that much time in Python? 回答1: Here is it, i found a solution. The fastest way to

openpyxl: AttributeError: 'MergedCell' object attribute 'value' is read-only

跟風遠走 提交于 2020-12-10 04:29:26
问题 When i'm trying to fill the cell in existing .xlsx file and then save it to a new one I got message: import openpyxl path = "/home/karol/Dokumenty/wzor.xlsx" wb_obj = openpyxl.load_workbook(path) sheet_obj = wb_obj.active new_protokol = sheet_obj firma = input("Podaj nazwe: ") nazwa_pliku = "Protokol odczytu" filename = nazwa_pliku + firma + ".xlsx" sheet_obj["C1"] = firma sheet_obj["D1"] = input() new_protokol.save(filename=filename) Traceback (most recent call last): File "/home/karol

Openpyxl: “permission denied” but Excel sheet not open

痴心易碎 提交于 2020-12-08 04:48:10
问题 I have a piece of code I've been using successfully for quite a while. There is a piece of it that loops through a small list of employees and writes each of their top 20 products to an Excel sheet. Now it is often (but not always) throwing an error: (see below for full traceback) PermissionError: [Errno 13] Permission denied: I.e., the error you'd get if you accidentally had the spreadsheet open when running the code. This is not the case now. Here's the relevant code: for e in employee_list

Openpyxl: “permission denied” but Excel sheet not open

大憨熊 提交于 2020-12-08 04:47:57
问题 I have a piece of code I've been using successfully for quite a while. There is a piece of it that loops through a small list of employees and writes each of their top 20 products to an Excel sheet. Now it is often (but not always) throwing an error: (see below for full traceback) PermissionError: [Errno 13] Permission denied: I.e., the error you'd get if you accidentally had the spreadsheet open when running the code. This is not the case now. Here's the relevant code: for e in employee_list

用 Python 帮运营妹纸快速搞定 Excel 文档

余生长醉 提交于 2020-11-18 09:45:45
Microsoft Office 被广泛用于商务和运营分析中, 其中 Excel 尤其受欢迎。Excel 可以用于存储表格数据、创建报告、图形趋势等。在深入研究用 Python 处理 Excel 文档之前,让我们先了解一些基本术语: Spreadsheet(电子表格) 或者 Workbook(工作簿) – 指文件本身(.xls or .xlsx). Worksheet(工作表) 或者 Sheet(表)–工作簿中的单个内容表,电子表格可以包含多个工作表。 Column(列) – 用英文字母标记的垂直数列,以“ A”开头。 Row(行) – 从1开始以数字标记的水平数列。 Cell(单元格) – 列和行的组合,例如“ A1”。 在本文中,我们来使用Python处理Excel电子表格。您将了解以下内容: Python 读写 Excel 的第三方库 从工作簿中获取工作表 读取单元格数据 遍历行和列 写入 Excel 电子表格 添加和删除工作表 添加和删除行和列 大多数公司和大学都使用Excel,它可以用多种不同方式使用,并可以使用Visual Basic for Applications(VBA)进行增强。但是,VBA有点笨拙,这就是为什么要学习如何将 Excel 与 Python 结合使用。 现在让我们了解如何使用 Python 处理 Microsoft Excel 电子表格!