Can you use python to access PowerPoint add in functions? - python

I am creating multiple powerpoint decks that have data modified but I need to be able to hit this "refresh slides" button that accesses the updated data from a connected website. Is there a way to do this automatically in python?

No, there is not. However, there is a workaround:
You have to put your data in single .xslx (Excel) files
Use this data within you PowerPointPresentation (see here for a description)
Write a script to refresh your data and output them into the .xlsx files
If you have done everything correctly, next time you open PowerPoint it will ask you, whether or not it should refresh the tables/graphs.
That is the only work around I have found in order to refresh PowerPointPresentations.

Related

How do I make my program independent of an excel sheet it currently relies on?

I'm designing a program in python tkinter that displays information that's currently in an excel spreadsheet. Ideally, I'd like to be able to share this program without needing to share the excel book as well. Is it possible to import the excel book into the program to make the program independent of that excel file? Let me know if I can provide any more clarification. Thank you!
You would need to assign the Excel file's content to a variable in your program to do so. I hope it isn't very large, but to make it easier I recommend:
saving your Excel file to .csv format
read it from Pytho
convert it to the data type you want (ex: string, list, ...)
save it back to a .txt file.
Now just copy the content of your .txt and assign that to a variable somewhere in your code.
Edit: what Alphy13 said is also a solution
Typically its best to create an example workbook that you can share. Give it all of the right parameters and leave out the sensitive data, or fill it in with fake data.
You could also set all of the variables that come from the excel file to have a default value that only changes when the workbook is present. This can be the first step toward creating proper error handling for your program.

What is the correct way to upload files to a SQL Server inside my web application?

I am developing a web application in which users can upload excel files. I know I can use the OPENROWSET function to read data from excel into a SQL Server but I am refraining from doing so because this function requires a file path.
It seems kind of indirect as I am uploading a file to a directory and then telling SQL Server go look in that directory for the file instead of just giving SQL Server the file.
The other option would be to read the Excel file into a pandas dataframe and then use the to_sql function but pandas read_excel function is quite slow and the other method I am sure would be faster.
Which of these two methods is "correct" when handling file uploads from a web application?
If the first method is not frowned upon or "incorrect", then I am almost certain it is faster and will use that. I just want an experienced developers thoughts or opinions. The webapp's backend is Python and flask.
If I am understanding your question correctly, you are trying to load the contents of an xls(s) file into a SQLServer database. This is actually not trivial to do, as depending on what is in the Excel file you might want to have one table, or more probably multiple tables based on the data. So I would step back for a bit and ask three questions:
What is the data I need to save and how should that data be structured in my SQL tables. Forget about excel at this point -- maybe just examine the first row of data and see how you need to save it.
How do I get the file into my web application? For example, when the user uploads a file you would want to use a POST form and send the file data to your server and your server to save that file (for example, either on S3, or in a /tmp folder, or into memory for temporary processing).
Now that you know what your input is (the xls(x) file and its location) and how you need to save your data (the sql schema), now it's time to decide what the best tool for the job is. Pandas is probably not going to be a good tool, unless you literally just want to load the file and dump it as-is with minimal (if any) changes to a single table. At this point I would suggest using something like xlrd if only xls files, or openpyxl for xls and xlsx files. This way you can shape your data any way you want. For example, if the user enters in malformed dates; empty cells (should they default to something?); mismatched types, etc.
In other words, the task you're describing is not trivial at all. It will take quite a bit of planning and designing, and then quite a good deal of python code once you have your design decided. Feel free to ask more questions here for more specific questions if you need to (for example, how to capture the POST data in a file update or whatever you need help with).

Any quick way to export data from Filemaker?

As a user of the database, are there any quicker ways of exporting data from Filemaker using languages like python or java? Perhaps to an Excel.
My job involves exporting selected data constantly from our company's Filemaker database. However, the software is super slow, and the design of our app is bad which makes selecting which data to export a pain. (I have to manually select data one by one by opening the full record of each data. There's no batch export function.)
Please provide me with alternative methods. I feel very stupid in doing this.
i always assume there is an easier way to do it.
having not done it myself, i would try this method:
http://agsci.psu.edu/it/how-to/convert-filemaker-pro-4-data-to-excel-export-as-merge-text-file
Convert FileMaker Pro 4 Data to Excel (Export as Merge Text File)
FileMaker Pro version 4 (FMP4) has the ability to export a text file that can be inserted into Excel 2013 or 2016. Note: Other higher versions of FMP can do this as well. These steps focus on FMP4 specifically.
Note: You should have saved the FileMaker Pro file to a known location on your computer. You will need to locate it with Excel.
Open the FileMaker file. Find the records you wish to export to Excel.
From the File menu choose Import/Export then Export Records.
From the Save as type box choose Merge (*.MER).
In the File name box, enter a name for the exported file. Be sure to add the .TXT extension rather than .MER.
You can choose to save the file to the desktop or to the same folder as the FileMaker file.
Click Save.
From the left side, double click on the field names you wish to export. Their names will appear on the right side.
Note: Once the names are on the right side, you can re-order them by clicking and holding on the double sided arrows beside their name. Move up or down as needed. This becomes the export order.
Click Export. This wil create the text file to be imported with Excel.
Open a blank or existing Excel 2013 or 2016 spreadsheet.
Click the Data tab on the Ribbon and choose From Text.
Choose the text file you want to import and double click.
This will open the Text Import Wizard. Your data type will be Delimited. Click Next.
For the Delimiter, un-check the Tab box. Then check the Comma box.
The Text qualifier should be a double quote.
Click Finish.
A final window will be displayed asking where you wish to put the data into the sheet. Chose A1.
Click OK.
Your data will now be in Excel.
You can also save records as a spreadsheet for use in Microsoft Excel. For more information, see Saving and sending records as an Excel file in the FileMaker Help file. Use export when you want to export records in the current found set or export in a format other than an Excel spreadsheet. Use Save as Excel when you want to create an Excel spreadsheet that contains all the fields you have access to on the current layout.
If your FileMaker Pro source file contains summary fields, you can group by a sorted field in order to export subsummary values, such as subtotals generated by a report with grouped data. This process exports one record for each group. For example, if you have a report that totals sales by region, you can export one summary value for each region.

Creating a Case in PSSE

I have data in an excel file that I would like to use to create a case in PSSE. The data is organized as it would appear in a case in PSSE (ie. for bus Bus number, name, base kV, and so on. Of course the data can be entered manually but I'm working with over 500 buses. I have tried copied and pasting, but that seems to works only sometimes. For machine data, it barely works.
Is there a way to import this data to PSSE from an excel file? I have recently started running PSSE with Python, and maybe there is a way to do this?
--
MK.
Yes. You can import data from an excel file into PSSE using the python package xlrt, however, I would reccomend instead converting your excel file to csv before you import and use csv as it is much easier. Importing data using the API is not just a copy and paste job, into the nicely tabulated spreadsheet that PSSE has in its case data.
Refer to the API documentation for PSSE, chapter II. Search this function, BUS_DATA_2. You will see that you can create buses with this function.
So your job should be three fold.
Import the csv file data with each line being a list of each data parameter for your bus. Like voltage, name, baseKV, PU etc. Store it to another list.
Iterate through the new list you just created and call:
ierr = bus_data_2(i, intgar, realar, name)
and pass in your data from the csv file. (see PSSE API documentation on how to do this) This will effectively load data from the csv file to your case ( in the form of nodes or buses).
After you are finished, you will need to call a function called psspy.save("Casename.sav") to save your work in a new PSSE case.
Note: there are functions to load in line data, fix shunt data, generator data etc.
Your other option is to call up the PTI folks as they can give you training.
Good luck
If you have an Excel data file with exactly the same "format" and same "info" as the regular case file (.sav), try this:
Open any small example .sav file from the example sub-folder PSSE's installation folder
Copy the corresponding spreadsheet to the working case (shown in spreadsheet view) with the same "info" (say, bus, branch,etc.) in PSSE GUI
After finishing copying everything, then save the edited working case in GUI as a new working case.
If this doesn't work, I suggest you to ask this question on forum of "Python for Power Systems":
https://psspy.org/psse-help-forum/questions/

How to check out a shared document using Python 3

I wrote a program that lets end users add/edit data from an Excel spreadsheet. This spreadsheet is a company wide shared document, and therefore it requires users to check out the document before making any changes to it. Is there a way to programmatically check out the document using Python or any other ways that would integrate with Python well?
Thanks in advance!

Categories

Resources