I'm trying to fetch tagged data from a .xls file.
I am able to fetch the tagged data from .xlsx file using Openpyxl, like this: [dn for dn in wb.defined_names.definedName]
But openpyxl does not support .xls format and I need to get the defined_names from .xls file as well.
Is there any library that can read .xls and return the defined_names in the file?
check xlrd package.
Here is the relevant part of the docs - Named references, constants, formulas, and macros
Related
I have a DataFrame that I would like to store as a CSV file in a Sharepoint.
It seems that the only way is to first save CSV file locally and then, using Shareplum, upload file to Sharepoint.
Is there a way to directly save DataFrame into Sharepoint as CSV file, without creating a local file?
Thanks a lot for your help.
It should be possible to write the csv content to an in-memory text buffer (e.g. StringIO or ByteIO) rather than to a local file - here is an example (last section of the page).
After that, you could use a library for writing the content directly to a Sharepoint: This discussion shows several approaches how to do that, including the Office365-REST-Python-Client and also SharePlum, which you have already mentioned.
Here are two more sources (Microsoft technical doc) that you might find useful:
How can I upload a file to Sharepoint using Python?
How to get and upload files from sharepoint with python?
I would like to write into an existing xlsx file in SharePoint. Is that even possible? Mydata is in the form of a dataframe and if possible, just append the dataframe instead of overwriting the whole xlsx file. I tried to use xlsxwriter library but did not get anywhere. Any help would be appreciated
#Coder123,
As you're using SP Online, you could update the content of xlsx file stored in SPO via MS Graph API:
https://learn.microsoft.com/en-us/graph/api/table-update?view=graph-rest-1.0&tabs=http
through this API, you can update the table/worksheet of an xlsx file. And it has offered a python library:
https://github.com/microsoftgraph/msgraph-sdk-python-core
I must create a web app with django that reads an xlsx file, a csv file and after their "data analysis" create a third xlsx file that contains the results of the data analysis.
My question is that: which libraries may I use to do that?
I recommend you to use xlrd https://pypi.python.org/pypi/xlrd library.
I have a web application (based on Django 1.5) wherein a user uploads a spreadsheet file.
I've been using xlrd for manipulating xls files and looked into openpyxl which claims to support xlsx/xlsm files.
So is there a common way to read/write both xls and xlsx files?
Another option could be to convert the uploaded file to xls and use xlrd. For this I looked into gnumeric and ssconvert, this would be favorable since all my existing code in written using xlrd and I will not have to change the existing codebase.
So should I change the library I use or go with the conversion solution?
Thanks in advance.
xlrd can read both xlsx and xls files, so it's probably simplest to use that. Support for xlsx isn't as extensive as openpyxl but should be sufficient.
There's a risk of losing information in converting xlsx to xls because xlsx files can be much larger.
Is there any way to read comments in xlsx files using python?
openpyxl enables the manipulation of xlsx files and there is discussion here of adding the ability to access comments. If this does not work the comments for a given xlsx file can be accessed in xml format by renaming and unzipping the xlsx file as described here. This xml file can then be read by python.