Python script to automate tasks with Excel - python

First of all I am very sorry if this is a common questions, however I am still very new in the programming world, and cannot figure out the keywords for what I'm actually looking for.
Basically I have an Excel spreadsheet with data Picture of Excel Sheet - For each identifier I have a 0 or a 1. My task is to copy the number in the identifier column, paste it into a webpage from my workplace and click a button to exclude the customer from billing. Once I have done this, I will go back to the Excel spreadsheet and change the number from 0 to 1. Since there is a lot to go through, I thought this would be a fun project for me to start learning a basic script. I did not make it very far though!
import pandas as pd
Migreringer = pd.read_excel('Migreringer.xls')
ExludeBilling = Migreringer[["Exclude Billing", "Identifier"]]
IsExcludedBilling = Migreringer["Exclude Billing"] > 0
I was hoping that someone was able to give me a good idea as to how to move on from here, My idea is that it would check each row for the True/False statement from IsExcludedBilling, and then as a start copy the identifier if the statement is False and paste it into a word document or something similar to test this out? I just cannot seem to figure out how to make Python go through each row and validate the statements, and then make it copy something from a different column in the same row to a different document?
I know from experience that I am more motivated in learning with a project in mind, so that is why I've chosen to start here. Maybe I should take a couple of steps back before engaging with a project like this?

do you wan this ?
df = pd.DataFrame(
{
'Exclude Billing': [1,0,0,1,0],
'Identifier': [ 41823,41835,41819,41798,41812],
}
)
df_zero=df.loc[df['Exclude Billing']==0,:]
df_zero.to_csv('data_with_zero.csv',index=False)

Related

Python Report Writing with flexible templates for report body rows

I have a need to create reports from Python. Our existing reporting system for my Volunteer Fire Company is being deprecated, and it had some idiosyncrasies anyway. Everything I'm looking at that seems feasible uses a template for the report body. Before I get too far down a dead end path trying different methods, I'd like to know if anyone knows of anything out there that can do something like this. Specifically, conditional formatting in a row in the body. Below is what we get currently- today I do the bolding of the rows manually based on our criteria of 33% or better. In my code I'll obviously know if the row deserves to be bolded- but everything I'm looking at that uses a template wouldn't allow this. The end result will be a PDF, but if I have to go through Excel, Word, HTML, or whatever to get there, I'll check it out. Sorry for the non-specific question, but I could potentially churn a lot more wasted time looking for something when somebody may already know what to use. Thanks.

Extract certain data from excel with Python to .ini-file

Hi I have a spreadsheet with different values in column A(DeviceName) and B(SystemIP).
I want to copy these 2 values into an .ini-file.
The .ini-file should basically be this below. With the IP and Devicename being dynamic and will get its value from an .xlsx-file.
[Network]
SystemIP=0.0.0.0
SubnetMask=255.255.255.0
DefaultGateway=10.0.0.1
[Device]
DeviceName=XXXX
MAC=12:32:FA:AB:D2
I've tested some things with Pandas to read the excel-file, however it doesnt really work the way I want.
If anyone could guide me in the right direction to manage this with a Python script I'd really appreciate it!

How do i access JSON data to send to Pandas?

I make a call to an API and get a JSON response. For the better half of 2 days i have been trying to access the data, and send it to a CSV file, or push it to Pandas with no luck. I have gone through page after page of assistance, but something is just not clicking.
Below is the JSON data, all i need are the following elements singleLineAddress, isAgentsAdvice & contractDate
[
{
"_embedded":{
"propertySummaryList":[
{
"propertySummary":{
"address":{
"singleLineAddress":"Example St"
},
"id":47328284,
"lastSaleDetail":{
"contractDate":"Example",
"isAgentsAdvice":Yes,
"isArmsLength":0,
"isPriceWithheld":0,
The ideal end result would be a csv export that had the following column names
Address | AA | Contract_Date
So far i've tried to create a simple dataframe in python, however it seems to always print on singular lines, so i moved over to attempting to 'flatten' the file for easier processing, but no data was extracted at all in those attempts.
I attempted to follow a few github recipes, but the overall theme seemed to be just flattening the data, which as above didnt seem to work well with my json file.
I attempted the normal dataframe route but didnt have much luck, my main focus has been in both json_normalize, and flatten_json type work, but if someone wants to offer a better solution, i am all ears.
Any help is appreciated. I'd appreciate any leads on what may be 'missing' from my knowledge base around JSON and Pandas as it's been quite handy the last few weeks.
Cheers

How to create pdfs from rows in a dataset and save them

Very general question here. Need ideas. I have a dataset with about 20 rows. I want to use python or R to automatically take each of these rows and create 1 pdf per row. The pdf is formatted in a particular way that I need to be able to play around with.
Imagine each row is a student's name, and I need to make a pdf "Report Card" for each student. The report card will have a designated spot that says "Math Grade" and then the value will come from the dataset.
I want to be able to hit run, and have all 20 of the pdfs save to a folder on my machine. Eventually, I may try to have this run on a server or something so it is fully automatic. The pdfs ultimately get emailed out to a distribution list.
I am very pretty familiar with R, and mildly familiar with Python. I have no experience in HTML, but is that what I need here?
Any tutorials, ideas, explanations of the process I should use would be appreciated.
I thought about using plot.ly.dash. But I think that is mostly for viewing in a web browser. I want pdfs, so I don't know if that will work.

I need a starting point to code an app to extract text from pdf to excel

To start I just want to state that I'm an Electrical Engineer with basic knowledge of programming.
My requirement is as follows:
I want to create an app where I can load and view PDF files that
contain tables.
These PDF files tables are of irregular shapes and in a different
position on every page. (that's why tools like tabular couldn't help
me)
Each table entry is multiline and of irregular dimensions (I cannot
select a whole row at a time it has to be each element alone. simply
copying the lines to excel won't work either because it will need a
lot of formatting)
So I want to be able to select each table entry individually from the
table (like a selection or cropping box over the required text),
delete new line if there is a new line in the text and just keep spaces.
The generated excel (or access database I do not really mind any)
should be reviewable and saveable (if those are even words XD).
I have a good knowledge of python and a very elementary knowledge of Django and I'm seeking some expert who can tell me what do I really need to learn (and if possible where to learn it) to execute my project.
Is it very much for me to execute and if I can dedicate 10 hours a week, how much would it take me to execute such a project.
Thanks all for your help in advance.
Don't use Python, use Word. Open the pdf, then step through the tables collection to collect the data and put it into excel. See this for an example
Here are the advises i can provide you :
first of all, ask internet for questions :
https://lmddgtfy.net/?q=python%20library%20tabular%20pdf
-> Camelot , which is mentioned multiple time seems to be relevant
For the use of excel sheet, i present you one of the most famous library for manipulating DataFrame: Pandas
You can use small courses on internet which will offer you a quick ability to manage your project easier.
for the application, you can easily find on youtube courses on a library made by someone who will explain you how to do a basic application. It could offer you the entry point you are talking about. Then, You can just wonder what else do you need or simply want for making it better.
for the time needed, it depends on how much time do you need to understand the basics, how much time you spend on having a deeper comprehension. I think in one week, working during your free time with a real interest, it could be working( not perfect, but working, which is a good beginning)
PS: I am not sure if your question is relevant for the aims of stackoverflow. I suggest you to read this file. ( https://stackoverflow.com/help/how-to-ask)

Categories

Resources