a simple visualization when write excel with python - python-3.x

this might be a stupid question but I need some insight
I currently already create an excel file with openpyxl. But now, I would like to add a visualization on the 4th column
I want to create a visual for two points like shown below
Pretty much a scale that shows the two points between actual vs reference. I don't know what to call this chart, but I found something really similar with sparkline (which is not what I am looking for).
Does anyone have any suggestion on what tool to use that can create this type of visualization when writing the file with python?
thank you

Related

Excel to PSPP without with hassle with variable names

I have some data in excel file. Now I need to find their significance value which is not possible with excel. It is only possible with PSPP. But when I import my excel file (after converting to csv file) to pspp it is making hell lot of problems specially with variable names.
Could anyone please tell me some easy solutions?
Excel to PSPP: Make sure your excel file is prepared:
Red boxes in the import-process of the cvs-file indicate problems in the rows, like words added in what otherwise looks like a variable with numeric values.
The variable names must not be too long so fix that first, it works like a very old version of SPSS in this respect.
Then look carefully at the steps when importing.
Choose the second row to be the first (as the first row is variable names, and not a case).
Then click the box for choosing the top row as variable names.
It is less smooth than SPSS in the initial procedure, but so fantastic with a free alternative to the SPSS.
When the dataset is ready, I found it worked well to do the same analyzes as in SPSS.
I suppose your problem is solved a long time ago, but maybe someone else may benefit from this.
A site for sharing information about the PSPP would be great...
One should first convert excel file into CSV (maybe through Apple Mac software Number) and then import the converted into PSPP software...easy

Dynamic Legend sorting by values in Excel

My graphed data has about 80 legend entries and I'm only interested in displaying the ones with the highest values attached.
Is there a way to do this in Excel 2010? Manual sorting is not a question, as the graph is operating on a dynamic range.
EDIT: After trying this, along with all the included troubleshooting comments, I still can't find a way of a dynamic legend. Moreover I got dv'd for almost no reason (no comment + dv -> not much help)
Using Python and not Excel is somewhat of an answer. Still interested if this is possible in Excel at all, but it doesn't look like it from my research + community response or should I say lack thereof.

Visio automatic container from lines

I'm using Visio Professional 2016. Is it possible to automatically create containers depending on a column (for example the project name) from external Excel data?
I found this but I'm not sure if this is want I'm looking for. Besides that it's not easy to follow.
Another question, where can I find settings similar to the properties mapper in yEd? I'd like to create shapes automatically from Excel data. If a new row is added in my external data it is supposed to create a new shape on its own.
Edit: Will this using VBA answer all my questions?

Plot every 2nd point in Excel using VBA

Is there a way to plot every 2nd point in Excel using VBA and not involving use of extra columns? Thanks.
I'm guessing you are plotting points to a line graph. Correct? If that's the case I wouldn't use VBA at all. Just make a custom range name selecting every other point. If you explain your situation a little better I might be able to help.

Working with Office "open" XML - just how hard is it?

I'm considering replacing a (very) large body of Office-automation code with something that works with the Office XML format directly. I'm just starting out, but already I'm worried that it's too big a task.
I'll be dealing with Word, Excel and PowerPoint. So far I've only looked at Word and Excel. It looks like Word documents should be reasonably easy to manipulate, but Excel workbooks look like a nightmare. For example...
In Word, it looks like you could delete a paragraph simply by deleting the corresponding "w:p" tag. However, the supplied code snippet for deleting a row in Excel takes about 150 lines of code(!).
The reason the Excel code is so big is that deleting a row means updating the row indexes of all the subsequent rows, fixing up the "shared strings" table, etc. According to a comment at the top, the code snippet is not even complete, in that it won't deal with a workbook that has tables in it (I can live with that).
What I'm not clear on is whether that's the only restriction that the sample code has. For example, would there also be a problem if the workbook contained a Pivot Table? Or a chart that references data from the same sheet? Or some named ranges? Wouldn't you also have to update the formulae for any cells (etc.) that referenced a row whose row index had changed?
[That's not to mention the "calc chain", which (thankfully) I think you can simply delete since it's only a chache that can be re-built.]
And that's my question, woolly though it is. Just how hard do you have to work do something as simple as deleting a row properly? Is it an insurmountable task?
Also, if there are other, similar issues either with Excel or with Word or PowerPoint, I'd love to hear about them now, before I waste too much time going down a blind alley. Thanks.
Having worked with the Open XML SDK 2.0 for almost two years now I can say that doing seemingly trivial tasks can take many hours and sometimes days to figure out how to do it properly. For example, deleting an Excel row should be fairly straightforward and easy to do right? Nope because not only do you need code to delete your row, but then you have to update all the row indices, update any merged cell references, update hyperlink references, etc. Our internal delete method is close to 500 lines of code to just delete a row and I'm sure we don't have all the cases accounted for either.
The biggest complaint I have is the lack of documentation on how to do the most common tasks. The MSDN section on the Open XML SDK is very limited and whenever you need to do anything complicated you are really on your own. I've had to read the Open XML standard a lot to figure out what certain elements mean and how they should be implemented since I could find very little online.
The other challenging part is if you insert an element in a spot where it doesn't belong or put an invalid attribute on an element you will get a corrupt file when you try and open it. Most of the time you will not get any information on what caused the error and you will have to look at the Open XML standard spec to see what you did wrong.
If you need a fast turnaround time on converting that Office automation code into Open XML and what you are doing is not really basic, then I would say pass. If you have time and the patience to read up on the Word, Excel and PowerPoint XML structures and get familiar with how they relate then I say go for it. In my opinion it is really the only way to have very fine control over these office documents, but there will be a great learning curve when you start.
Oh and just for fun here is how much code is needed to add a comment to an Excel cell.
Just for completeness, here are some libraries I found for working with Excel XML:
www.extremexml.com - a layer on top of the Open XML SDK classes; focusses on injecting data into an existing spreadsheet; handles many of the cross-reference problems I identified in my question. Open source but GPL2 not LGPL. Code looks nice, and documentation is excellent. Does not appear terribly active on codeplex though.
Closed XML - another layer on top of the Open XML SDK - again open source, but with a less restrictive license (MIT). Looks nice, and looks more "active" than the above.
SpreadsheetLight - from what I can tell, a closed-source library sitting atop the Open XML SDK classes. Targeted more at those looking to create a spreadsheet from scratch rather than making changes to existing spreadsheets.
Here is another third party library dedicated to working with OpenXML:
http://www.officewriter.com
In the example cited by amurra above of deleting Excel spreadsheet rows, this is a single method call with this tool. It updates formulas and all the other references for which it seems that 500 lines of code would be required for otherwise.
The OpenXML SDK itself is a great tool for very simple things, but you still have to concern yourself with a lot of the internals of the file format and packaging structure to get things really right.
Here are some additional libraries that can manipulate with OOXML formats:
- GemBox.Spreadsheet (XLSX)
- GemBox.Document (DOCX)
Also GemBox published some articles that demonstrate how to manipulate with OOXML file format with pure .NET (without a use of any library), I think you'll find this interesting:
www.codeproject.com/Articles/15593/Read-and-write-Open-XML-files-MS-Office
(Introduction to SpreadsheetML format and an explanation on how we can read and write worksheet's cell content)
www.codeproject.com/Articles/649064/Show-Word-File-in-WPF
(Introduction to WordprocessingML format and demonstration on how we can read document's text)

Resources