Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python program for excel
#1
Hello,
I am new to python and I work on excel everyday which is more of manual. I need to automate some part using python as I am interested in learning it. I need python gurus to help me in coding.
I have data in excel 1 which I need to read and then go to excel 2 find them in excel 2 and get the values in columns.
Below is the example data I have and rules on how to populate data

Read row 1 & column 1 from excel 1, go to excel 2 find AAAAAA and get value from column A and write to column 2 row 1
in excel 1
Always skip middle row if column 1 in excel 1 has more than two entries
Read row 3 & column 1 from excel 1, go to excel 2 find AAAAAA and get value from column B and write to column 2 row 3 in
excel 1
Excel 1 Excel 2
row column 1 column 2 column X column A column B
1 AAAAAA CCCCCC 20 30
2 AAAAAA AAAAAA 40 50
3 AAAAAA BBBBBB 10 30
4 BBBBBB
5 BBBBBB
6 CCCCCC
7 CCCCCC
8 CCCCCC

Result should be like below
Excel 1
row column 1 column2
1 AAAAAA 40
2 AAAAAA
3 AAAAAA 50
4 BBBBBB 10
5 BBBBBB 30
6 CCCCCC 20
7 CCCCCC
8 CCCCCC 30
Reply
#2
It's extremely unclear how your data in the 2 files look like and how you get the desired result.
That said we are glad to help but we are not great at writing code for people. Post your attempt to solve this task and ask specific questions. Don't forget to use BBCode tags as appropriate.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Let me point you in a general direction. There is a Python library called Pandas. It can read excel files directly, into a structure called a Dataframe. The Dataframe is like a spreadsheet and you have a ton of capabilities in that library to manipulate that dataframe.

For pretty data visualization you can then use the library Matplotlib. Very similar to Matlab. There are extensions from that - last night in a course I was making choropleth maps of San Francisco crime rates using Pandas, Matplotlib, and Folio. There are an amazing number of libraries that can help you with your projects, and we are happy to make suggestions.

This is a Youtube video, rather long, about Pandas. It uses Jupyter Notebooks, which is a great way to learn by breaking code into snippets and running the pieces - debug a task and move on. You can also start at the pandas website and look at the documentation, and there are lots of books and tutorials online.
Youtube video Pandas from the Ground Up from PyCon 2015
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Results of this program in an excel file eisamabodian 1 1,572 Feb-11-2022, 03:18 PM
Last Post: snippsat
  How can I speed up my openpyxl program reading Excel .xlsx files? deac33 0 3,391 May-04-2020, 08:02 PM
Last Post: deac33
  Program writing excel rfile with randomnized input wepkes 1 3,665 Dec-08-2016, 08:06 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020