More than 1,000 rows were deleted through openpyxl’s delete_rows, but the serial numbers in the result table were not reduced? (Book gift at the end of the article)…

Click “Python Crawler and Data Mining” above to follow

Reply “Books” to receive a total of 10 Python e-books from entry to advanced

now

day

chicken

Soup

But I saw mourning birds calling old trees, and male and female flying around the forest.

Hello everyone, I am Pippi.

1. Foreword

A few days ago, in the group of Python’s strongest kings [鶶ah鶶. 】Asked a question about automated office processing in Python. Let’s take a look.

Dear friends, I would like to ask: It turns out that my table serial number is more than 2,800 rows. I deleted more than 1,000 rows through delete_rows of openpyxl. However, in the result table, these serial numbers are not reduced, resulting in a large blank row. Is there any way to do this? Can it be handled?

e1048529d665b645118cbe32d82c09fa.png

2. Implementation process

Here [Wu Chaojian] gave a code as follows:

from openpyxl import load_workbook

#Open Excel file
workbook = load_workbook('111.xlsx')

# Select worksheet
worksheet = workbook['Sheet1'] # Replace 'Sheet1' with the actual worksheet name

# Delete a single line with line number 5, along with the format
worksheet.delete_rows(5)

# Delete lines with line numbers from 3 to 7 (including line numbers 3 and 7), along with the format
worksheet.delete_rows(3, 7)

# Save the updated Excel file
workbook.save('222.xlsx')

After the code was run, the test was correct. Later [Dong Ge] also tested it and found no problem.

ce5278bfebfa6c916f1c9ed5c4caa528.png

Later, fans added the following information themselves, as shown in the picture below:

e293687a7ba350174c2caf4b246a9746.png

Theoretically speaking, version 3.1.2 will not have this problem.

27d17c7909f75d0008334a910093b259.png

Later, [Next Door Hawthorn] gave a tip, as shown in the picture below, and successfully solved the fan’s problem.

8374f14f0d17c8a9c71827781a71fb74.png
Giving books

One sentence recommendation

BROKE, the original prompt word design framework that has exploded across the Internet, takes you in 5 steps to master the art of asking questions to artificial intelligence

Features

System: Comprehensive analysis of ChatGPT application skills, turning you from a novice into a ChatGPT application expert.

Practical: Contains “prompt formulas” that can be used out of the box, focusing on the practical application of ChatGPT.

There are ideas, there are methods, and they can be implemented: we will help you truly transform ChatGPT into productivity and start an AI-driven workflow.

Simple and easy to read: explained in simple terms, step by step, contains 60+ examples, suitable for beginners and advanced readers.

Depth: Combining theory with practice, covering in-depth discussions on engineering disciplines, giving a man a fish will teach him how to fish.

Introduction

This book is a toolkit for everyone, designed to help you master and effectively utilize AI tools represented by ChatGPT. After studying this book, you will be able to freely use ChatGPT in life and professional fields and become an advanced ChatGPT player.

This book is divided into 9 chapters, covering three levels: introduction and interpretation, introductory learning, and advanced improvement. Chapters 1 to 2 provide an in-depth introduction and analysis of ChatGPT and prompt engineering, and explore the prompt engineering discipline from multiple disciplines. Chapters 3 to 5 demonstrate the practical application of ChatGPT, teach you how to use ChatGPT to solve natural language processing problems, and provide you with a set of operable and repeatable prompt design frameworks so that you can master ChatGPT proficiently. Chapters 6 to 9 explain prompt engineering methods from academia and how to innovate around ChatGPT; in addition, they provide practical reference materials for readers who want to develop applications with ChatGPT, and introduce other options besides ChatGPT.

This book focuses on the practical application of ChatGPT, which is operable, repeatable, and easy to read without losing depth. Whether you are curious about ChatGPT and similar tools, or looking forward to turning them into productivity, this book is worth reading. In addition, this book can also be used as a teaching material for relevant training institutions.

Further reading

“ChatGPT Era: All-in-One ChatGPT Application”

0988331ee8b5e9c9d1eb41e38d63fc9e.png

About the author

Chen Haopeng, prompt engineer, AI product manager, graduated from the School of Computer Science, Beijing University of Posts and Telecommunications. He has accumulated industry experience in Didi Autonomous Driving, TuSimple, ByteDance, Meituan and other companies, and now works for a unicorn company in the AI field. As an early user after the release of ChatGPT, he used the technology to reshape the workflow and significantly improve work efficiency. The ChatGPT prompt design framework he invented has received 40,000 + likes and collections on Xiaohongshu (ID: Chen Caimao). It has been reprinted many times and shared widely within multiple companies. He is responsible for the writing of the main content of this book.

Li Zihan holds a master’s degree from the Department of Computer and Engineering of the Hong Kong University of Science and Technology and a bachelor’s degree from Beijing University of Posts and Telecommunications. The research areas involve large language models and prompts. His participation in related work has been published at ACL, the top academic conference in the field of natural language processing. He has an in-depth understanding of the field of artificial intelligence and various language models. She is the scientific consultant for this book, participated in the writing of the first chapter, and reviewed the book.

3. Summary

Hello everyone, I am Pippi. This article mainly takes stock of a problem of deleting columns in Python automated office Excel. The article provides specific analysis and code implementation for this problem, helping fans to solve the problem smoothly.

Finally, I would like to thank the fans [鶶ah鶶. ] asked the question. Thanks to [Wu Chaojian], [Brother Dong], and [Next Door Hawthorn] for their ideas and code analysis. Thanks to [Snow Mountain Fat Fox] and others for participating in learning and exchanges.

[Question supplement] Warm reminder, when everyone asks questions in the group. You can pay attention to the following points: If it involves large file data, you can desensitize the data, send some demo data (meaning small files), and then paste some code (the kind that can be copied), remember to send screenshots of errors (complete screenshots) ). If there is not much code, just send the code text directly. If the code exceeds 50 lines, just send a .py file.

caac32fe94dab8fae5dd33cdb8335f2b.png

If you encounter problems during the learning process, please feel free to contact me to solve them (my WeChat: pdcfighting1). At the request of fans, I created some ChatGPT robot communication groups and high-quality Python paid learning communication groups and paid order-taking groups. , welcome everyone to join my Python learning exchange group and order-taking group!

f9f65ef64aea25a5f970ebbaf95c5fab.png

Friends, try it out quickly! If you encounter any problems during the learning process, you are welcome to add me as a friend, and I will bring you into the Python learning exchange group to discuss and learn together.

581ed1dab071c93969f4fc713bac9bc6.jpeg

< /strong>—— –< /strong> End < /strong>

Recommended articles from past issues:

  • if a and b and c and d: Is there an elegant way to write this code?

  • What is the relationship between Pycharm and Python?

  • They all say that chatGPT programming is so powerful. I tried it today. There is a static web page, but chatGPT actually failed to handle it?

  • If you can’t stand still, prepare to increase your position. How should you write this pandas statement?

b53d938d5ae0de81360ef780a15429e3.png

Welcome everyone to like,leave a message,retweet, reprint,Thank you for your company and support.

If you want to join the Python learning group, please reply [Join the group] in the background

Love is always there in thousands of rivers and mountains, can you click [Looking]

/Today’s Message Topic/

Just say a word or two~~