My Google Docs getting weird in formatting and difficult to edit - python

Crop of my google docs
So, I don't know what happen to my google docs, but everything went well until I tried to open the ".xlsx" file using openpyxl module in Python
I am not sure as well if it was caused by the module itself or what caused the error in my google docs.
So, basically my google docs is getting difficult to be edited. When i tried to move my cursor at certain points, it always brings the cursor in the beginning of the sentence at particular line. Next if I type something it always appear at the section "IT APPEARS HERE". And last thing, if i type something without a space or enter, it will not type in the new line but it seems like just breaching the page border and goes beyond that. I don't know what is going on here.
I am wondering if it was caused by my trial & error in the python code (?), but seems like no direct correlation between that. So, yeah I need your advice on this guys.. I really appreciate your help

.xlsx is file format for Microsoft Excel, try opening with Google Sheets

Might be related to the issue described here: https://www.androidpolice.com/2021/04/14/if-youre-using-an-ad-blocker-in-google-docs-you-could-run-into-weird-problems/
Basically: Disable your adblocker for google docs for now.

Related

Libtorrent. Answer some questions

To begin with, English is not my native language, so it's hard for me to read the libtorrent documentation and all this question has been translated.
I ask you to answer these questions, if you know any of them, answer only him.
I am using libtorrent 2.0.7 and Python 3.8
It is not necessary to answer questions in python, I will try to figure it out even if you answer in c++
At the moment when the torrent is not loaded yet. How do I get all the files to be uploaded?
At the moment when the torrent is loaded. How do I get the path to the files that were uploaded?
(I found a similar question, but its answer stopped working because of deprecated)
I'm trying to use
handle.get_torrent_info()
to answer point 1, but returns
DeprecationWarning: get_torrent_info() is deprecated
I tried to look in the source file, but it doesn't say what to use instead of this function. Do you know?
I would like to set a download speed limit for the entire session. To do this, I found
session.download_rate_limit()
in its parameters , but when using it, it returns
DeprecationWarning: download_rate_limit() is deprecated.
I also tried to look in the documentation, but I didn't find it. I also didn't figure out what parameters it accepts, I tried int, but it returned an error. As in point 2, it is not written what to use instead of the outdated function. Do you know?
I would like the session to download only 1 torrent at a time, and the rest queued in the order of enabling the download from the pause state. How to do this, I do not know at all. Help please
I found the answer to the 1st and 2nd question:
test = handle.status()
for i in range(test.torrent_file.files().num_files()):
print(test.torrent_file.files().file_path(i))

downloading a CSV file without a direct link or API

I am trying to find a solution to download a CSV file from an internal company website.
My first thought was throught the API but it doesn't exit, at least not yet.
Second I figured, I would try a direct link to the CSV file on the website, that's also a No Go as the link is sort of static and even copy pasting to a new tab doesn't work.
My third idea was to record a mouse movement, but that's just too inefficient as I would like this process to happen in the background.
Please, I welcome any ideas, codes, software, anything.... most preferable solution would be in VBA after that python and then anything else.
I'm sorry if this is not stack overflow worthy question :/

Charts from Excel to PowerPoint with Python

I have an excel workbook that is created using an excellent "xlsxwriter" module. In this workbook, there about about 200 embedded charts. I am now trying to export all those charts into several power point presentations. Ideally, I want to preserve the original format and embedded data without linking to external excel work book.
I am sure there is a way to do this using VBA. But, I was wondering if there is a way to do this using Python. Is there a way to put xlsxwriter chart objects into powerpoints ?
I have looked at python-pptx and can't find anything about getting charts or data series from excel work book.
Any help is appreciated !
After spending hours of trying different things, I have found the solution to this problem. Hopefully,it will help someone save some time.The following code will copy all the charts from "workbook_with_charts.xlsx" to "Final_PowerPoint.pptx."
For some reason, that I am yet to understand, it works better when running this Python program from CMD terminal. It sometimes breaks down if you tried to run this several times, even though the first run is usually OK.
Another issue is that in the fifth line, if you make False using "presentation=PowerPoint.Presentations.Add(False)," it does not work with Microsoft Office 2013, even though both "True" and "False" will still work with Microsoft Office 2010.
It would be great if someone can clarify these about two issues.
# importing the necessary libraries
import win32com.client
from win32com.client import constants
PowerPoint=win32com.client.Dispatch("PowerPoint.Application")
Excel=win32com.client.Dispatch("Excel.Application")
presentation=PowerPoint.Presentations.Add(True)
workbook=Excel.Workbooks.Open(Filename="C:\\.........\\workbook_with_charts.xlsx",ReadOnly=1,UpdateLinks=False)
for ws in workbook.Worksheets:
for chart in ws.ChartObjects():
# Copying all the charts from excel
chart.Activate()
chart.Copy()
Slide=presentation.Slides.Add(presentation.Slides.Count+1,constants.ppLayoutBlank)
Slide.Shapes.PasteSpecial(constants.ppPasteShape)
# WE are going to make the title of slide the same chart title
# This is optional
textbox=Slide.Shapes.AddTextbox(1,100,100,200,300)
textbox.TextFrame.TextRange.Text=str(chart.Chart.ChartTitle.Text)
presentation.SaveAs("C:\\...........\\Final_PowerPoint.pptx")
presentation.Close()
workbook.Close()
print 'Charts Finished Copying to Powerpoint Presentation'
Excel.Quit()
PowerPoint.Quit()
The approach I'd be inclined toward with the current python-pptx version is to read the Excel sheets for their data and recreate the charts in python-pptx. That of course would require knowing what the chart formatting is, etc., so I could see why you might not want to do that.
Importing charts directly from Excel has been done in the past, see the pull request here on GitHub: https://github.com/scanny/python-pptx/pull/65
But it involved a large amount of surgery on python-pptx, and many versions back now, so at most it might be a good guide to what strategies might work. You'd need to want it pretty bad I suppose to go that route :)
I don't have enough reputation to comment but if you get the same issue as #R__raki__ then you can use the integer value defined by the VBA reference. For this case it would be 12.
So replace
Slide=presentation.Slides.Add(presentation.Slides.Count+1,constants.ppLayoutBlank)
with
Slide=presentation.Slides.Add(presentation.Slides.Count+1,12)
See here for more.

What is the equivalent of BlobstoreLineInputReader for targeting Google Cloud Storage?

This is a python appengine question, mapreduce library 1.9.21 .
I have code writing lines to a blob in the local blobstore, then processing that using mapreduce BlobstoreLineInputReader.
Given that the files api is going away, I thought I'd retarget all my processing to cloud storage.
I would expect to find a class called GoogleCloudStorageLineInputReader, but there isn't anything like that. Is it hiding somewhere?
Is there something way I can use GoogleCloudStorageInputReader to read lines?
Another possibility is using GoogleCloudStorageRecordInputReader, but for that my input file needs to be in LevelDB format and I don't know how to create that except with a GoogleCloudStorageConsistentRecordOutputWriter, which I don't know how to use outside a mapreduce context. How might I do that?
Or am I doing this all wrong, is there some other possibility I've missed?
At first, I attempted thinkjson's CloudStorageLineInputReader but had no success.
Then I found this pull request...which led me to rbruyere's fork. Despite some linting issues (like the spelling on GoolgeCloudStorageLineInputReader), however at the bottom of the pull request it is mentioned that it works fine, and asks if the project needs to be taken over.
Hope that helps!

xgoogle python library is not working any more?

I was using the xgoogle python library for one of my projects. It was working fine till recently. I am not getting the resultset that I used to get before. If anyone who has used this library written by Peter Krummins, faced a similar situation, can you please suggest a work around ?
The presence of BeautifulSoup.py hints that this library uses web scraping to get its result.
A common problem with this is that it will easily break when the design/layout of the page being scraped changes. And the problem you see seems to coincide with the new search results layout that Google introduced just recently.
Another problem is that it often is against the terms of service of the site being scraped. And according to point 5.3 of the Google Terms Of Service it actually is:
You specifically agree not to access (or attempt to access) any of the Services through any automated means (including use of scripts or web crawlers) [...]
A better idea would be to use the Custom Search API.
Peter Krumin's product xgoogle looks to be extremely useful both to me and I image many others.
https://github.com/pkrumins/xgoogle
For me the current version is 1.3 is not working.
I tried a new install from GitHub, ran the examples and nothing is returned.
Adding a debugger to the source code and tracing the data captured in a query to its disappearance the problem occurs in a routine called search.py subroutine "_extract_results" at a parser command
results = soup.findAll('li', {'class': 'g'})
The soup object has material in it but the "findAll" fails to return anything.
Looks like its searching for lists and if there are none it returns nothing.
I am unsure what html you would try to match to get a result.
If anyone knows how to make the is work I am very interested.
A little more googling and it appears xgoogle is no longer supported or works.
Part of the trouble is that Google changes the layout of its results pages every so often and so any scraping software that assumes some standard layout is in time doomed to failure.
There are however other search engines that are locally installed and thus provide a results layout that are less likely change with upgrades and will not change at all if you don't upgrade.
I am currently investigating Yacy. Easy to install and can be pointed at specific sites if you want.

Categories

Resources