Synchronization using python code based on an excel file to JIRA - python

I am using python package 'jira' for establishing connection with the jira. I basically use the information from excel file and create tickets automatically in JIRA based on the excel information. Sometime there might be changes in the excel information for the same ticket in which case I need to run the code manually. So I would like to know if it is possible to do this automatically whenever there is a change in the excel file.

I assume you are only interested in filing new tickets. i.e. adding new rows in excel sheet.
Two options:
Run your code in a forever loop with sleep.
Have your code run by a cron.
Now, you can maintain the hash(md5 or sha256) of your file, and write the hash in some file on host machine if you are not using a database.
Your code has to read from this file, and calculate fresh hash of that excel file. If they are not same, means something has changed in your file.
Now, you also need to maintain till what row you have created the jira tickets. You can write this information also in some file.

Related

Is there a way to grab the most up-to-date CSV (appends every 5 mins) file into my Rust program?

I have a python script that runs in the background which creates a csv file and appends new lines to the CSV file every 5 minutes when new data comes in. I would like to read this CSV file in my Rust application but also grab the new changes when new data comes in.
I see you can use the notify crate to check for changes in a directory or file. Would this be a good way to go about it?
Does anyone have a solution for this? Every row has timestamps in the CSV file and I can also get sequence number/index in the CSV if that can help. Thank you so much!
I have managed to read an entire CSV file and store it as records in Rust via tutorials but I don't understand how to scan for changes and add the new records into the rust program. I have also tried to use the notify crate separately but I am not sure if I need a debouncer to scan for changes in the csv file or use the regular example in the docs.
Using csv package with serde in Rust.

Write data with Python into existing excel file keeping it intact as much as possible

We have a rather complicated Excel based VBA Tool that shall be replaced by a proper Database and Python based application step by step.
There will be time of the transition between were the not yet completely ready Python tool and the already existing VBA solution will coexist.
To allow interoperability the Python tool must be able to export the database values into the Excel VBA Tool keeping it intact. Meaning that not only all VBA codes have to work as expected but also Shapes, Special Formats etc, Checkboxes etc. have to work after the export.
Currently a simple:
from openpyxl import load_workbook
wb = load_workbook(r'Tool.xlsm', keep_vba=True)
# Write some data i.e. (not required to destroy the file)
wb["SomeSheet!SomeCell"] = "SomeValue"
wb.save(r"Tool_filled.xlsm")
will destroy the file, i.e. shapes won't work, checkboxes neither. (The resulting file is only 5 MB from originally 8 MB, showing that something went quite wrong).
Is there a way to only modify only the data of an ExcelSheet keeping everything else intact/untouched?
As far I know an Excel Sheet are only zipped .xml files. So it should be possible to edit only the related sheets? Correct?
Is there a more comfortable way as writing everything from scratch to only modify the data of an existing Excel file?
Note: The solution has to work in Linux, so simple remote Excel calls are not an option.

Python: how to start Excell add-in, request data, and save?

I have an excel add-in (morningstar) that allows me to request and download data by entering a function with some parameters in cell A1. I have a thousand values of parameters that I need to get the data for so I would want to automate this process. I can (sort of) do that with VBA but it takes forever, and crashes many times. I would like to do this in Python. The logic which I am doing in VBA is as follows:
Open the xlsx file (workbook)
Refresh Excel so to make sure the Add-in is loaded and data is downloaded
Loop through sheets and save as csv files
I tried opening the excel file with python using the subprocess package. But I cannot make it until the data is downloaded. I attached 2 photos of the download process: (i)when the function in cell A1 is executed, the cell display "Processing..." . It would take a few seconds to a few minutes depending on the size of the data. when done, the data looks like in the second photo.
So my questions are:
How to ask python to start excel and load the add-in?
Execute the fuction in cell A1, or at least refresh excel to make sure the function runs.
Instead of asking python to wait for an exact time, how do I ask python to check if the data is downloaded?
Ideally, (I think) doing this without opening excel would save a lot of time, but not a major issue.

Appending Bash Script Output To Excel

I have a peculiar situation lets do a background.
Background:
We have a script that was developed in house for testing enterprise servers. The script is written in Bash. The magic of the script is the dmidecode command. The script runs on Linux Mint and is deployed via PXE. The output of the script contains hardware information about the processor, memory, system board and chassis part numbers, etc. This information is always changing depending on the device the image is booted on. All this data is then grepped into a readable format that then manually gets added into an Excel spreadsheet. The Excel sheet is broken up like this Row 1: A1(Asset Number),B1(Qty."always 1"),C1(Manufacturer),D1(Model),E1(Part Number),F1(Serial Number), G1(RAM (Mb)),H1(# of CPUs),L1(CPU Speed(GHZ))
Example Data
Column Names:
Column Data:
Row 2: 6112, 1, HP, Proliant DL580 G2, 325134-001, USE247ML97, 1024, 2, 2.8
So each row represents an individual server, the columns contain the data that comes from our previously mentioned bash script.
Goal:
OK, so my goal is to have the output of the bash script automatically be appended to an existing Worksheet that is stored on a local CIFS File Server. Since script is initiated on Linux, Powershell is not a viable option.
I think Openpyxl can do the job but I have no idea the best practice to approach this. I know that I will not be able to modify an existing workbook. Given that, I was thinking about loading an existing document in memory and overwriting with the same file name. Also, all the tutorials I see for Openpyxl seem to have static data, I do not have this luxury. Is this even possible or just a subtle daydream?
For an excel sheet i would use XLSX parser to read the spreadsheet and XLSX writer to make a whole new spreadsheet based on what you have read. However, for what you appear to be doing. Would it not be easier to put STDIO into a CSV?
e.g,
echo $VAR , $VARB , $VARC >> ~/servers.csv

update/insert access database using python

Is it possible in python by which I can write a simple .py script to update my access database records or insert new one if any i have on behalf of me? new records are to be pulled from Excel and pushed to be in the database.
MS-Access2010 i am using.
Thanks,
It's definitely possible. You'll probably want to do it with the comtypes module, which allows communication between Windows processes using the Component Object Model (COM).
Here's an example of a script that does that posted in another question.
Getting the information out of Microsoft Excel can be done with a lot of modules, but one I've had success with is openpyxl. Some examples of reading Excel workbooks with it can be found here.

Categories