from openpyxl import load_workbook
input_file = "input.xlsx"
output_file = "output.xlsx"
wb = load_workbook(input_file)
wb.save(output_file)
My input file contains some image file. But while loading it and saving it again all the images are lost from my excel workbook. Please resolve this issue.
Thank you
I encountered the same problem until I installed the library Pillow.
Check it out: https://pillow.readthedocs.io/en/stable/installation.html
either add it to your requirements.txt or install it using the command
pip install Pillow>=8.3.2
Hope that helped ^^
As of now, openpyxl does not read all elements present in a Excel file. (See official openpyxl docs: https://openpyxl.readthedocs.io/en/default/usage.html)
Essentially, your images aren't showing up because openpyxl doesn't know how to read images.
Try using an alternative library like XlsxWriter (PyPi Page: https://pypi.org/project/XlsxWriter/)
Hope this answer helps!
Happy Coding ~
Related
This is the error message i am getting .Even on trying the code given by my tutor and online i tried fixing but ended up being not able to fix the problem
You're requesting Pandas to use the xlsxwriter engine to write your XLSX file. The error says
ModuleNotFoundError: No module named 'xlsxwriter'
To use the xlsxwriter engine, you'll need to install the xlsxwriter module.
Usually, that's done with pip install xlsxwriter.
I have been searching the web for hours trying to find something that might help me convert a file that was saved in the ppt file type to the pptx file type using python. I found "python-pptx" and was planning on using it to save the files, however this was not possible due to the continuous error:
Package not found at 'FileName.ppt'
I discovered another post (Convert ppt file to pptx in Python) which did not help me at all. I assume it is because my python version might be too high. (3.9) After reading up on getting the win32com.client to work and installing multiple pip and pip3 commands, it is still not working. If anyone could assist me with this manner I would be very thankful. My Current Code:
from pptx import *
prs = Presentation("FileName.ppt")
prs.save("FileName.pptx")
You can use Aspose.Slides for .NET and Python.NET package for converting PPT to PPTX as shown below:
import clr
clr.AddReference('Aspose.Slides')
from Aspose.Slides import Presentation
from Aspose.Slides.Export import SaveFormat
# Instantiate a Presentation object that represents a PPT file
presentation = Presentation("presentation.ppt")
# Save the presentation as PPTX
presentation.Save("presentation.pptx", SaveFormat.Pptx)
Our web applications use our libraries and you can see conversion results here.
I work at Aspose.
I doubt python-pptx can parse a .ppt file. (It's a completely different file format.) You're better off automating PowerPoint itself - somehow - to read one and write the other.
The "somehow" depends on the platform you're running on - and the automation capabilities available to you.
Hope you'll are doing good. I am new to python. I am trying to use audio.scikits library in python3 verion. I have a working code version in 2.7(with audio.scikits) . While I am running with python3 version I am getting the Import Error: No Module Named 'Version' error. I get to know that python3 is not anymore supporting audio.scikits(If I am not wrong). Can anyone suggest me replacing library for audio.scikits where I can use all the functionalities like audio.scikits do OR any other solution which might helps me. Thanks in advance.
2.7 Version Code :
from scikits.audiolab import Format, Sndfile
from scipy.signal import firwin, lfilter
array = np.array(all)
fmt = Format('flac', 'pcm16')
nchannels = 1
cd, FileNameTmp = mkstemp('TmpSpeechFile.wav')
# making the file .flac
afile = Sndfile(FileNameTmp, 'w', fmt, nchannels, RawRate)
#writing in the file
afile.write_frames(array)
SendSpeech(FileNameTmp)
To check entire code please visit :Google Asterisk Reference Code(modifying based on this code)
I want to modify this code with python3 supported libraries. Here I am doing this for Asterisk-Microsoft-Speech To Text SDK.
Firstly the link code you paste is Asterisk-Google-Speech-Recognition, it's not the Microsoft-Speech-To-Text, if you want get a sample about Microsoft-Speech-To-Text you could refer to the official doc:Recognize speech from an audio file.
And about your problem you said, yes it's not completely compatible, in the github issue there is a solution for it, you could refer to this comment.
I am a new learner.Maybe it's A Stupid Question. I use below code try to write something in sheet :'new' in 'or.xlsx'. but after i finised ran my code. nothing was been writer in that sheet. No error was pop up.Here is the code :
from xlrd import open_workbook
import xlwt
wb = xlwt.Workbook('D:\Work\xxx\xx\python\or.xlsx')
ws = wb.add_sheet(u'new', cell_overwrite_ok=True)
ws.write(0, 0, u'523123')
wb.save('or.xlsx')
IDE: Pycharm
python 2.7.13
drop the first line, xlrd is not used in the remainder of the code.
xlwt writes XLS files, not XLSX.
The first arg of xlwt.Workbook is NOT a file path! Pls review the docs.
import xlwt
wb = xlwt.Workbook()
sheet1 = wb.add_sheet('Sheet 1')
wb.save('self, example.xls')
I am trying to learn how to create xls, edit xls, or delete if neccesary on python. I had verymuch trouble on this because every tutorial online doesn't mentions that I should put xlwt before Workbook but I figure it out now. The problem is when I run this code I get an error wich it says "ValueError: cannot use LOCALE flag with a str pattern" I don't even know what that means... What is it about and how can I fix it?
There is a known-issue with tablib and Python 3.6, looks like it will be solved in the next releases.
For now, I make it work just downgrading to python 3.5.2
I had a similar problem and i resolved it by changing my series to "str" data type. df.astype("str")
Also not sure why you are trying to save your file as "self, example.xls". Could you print the entire error as it was given.