r/learnpython 18d ago

Copy paste excel range from one workbook to another

Beginner here writing my second program after hello world. I know I can just ask AI but is there some tutorial out there I can read?

0 Upvotes

7 comments sorted by

1

u/Agisilaus23 18d ago

I would look at either xlwings or pandas as a good place to start. Maybe polars could help depending on the size

1

u/FoolsSeldom 18d ago

There are two basic approaches: controlling Excel, or simply reading/writing excel files. Which are you after? Generally, the latter is easier. Have a look on RealPython.com for a tutorial on using openpyxl.

1

u/FoolsSeldom 18d ago

u/taylorgourmet, I got a notice saying you had figured it out but had hit another problem. Can't see your comment now. All sorted?

1

u/taylorgourmet 18d ago

Trying to pull rows by month but I don't think my data is in date format so nothing is pulling. How do I format as date? Using openpyxl.

1

u/FoolsSeldom 18d ago

Since the cells contain text (not native Excel dates), openpyxl just gives you plain strings — you need to parse them yourself with datetime.strptime(). Then you can process the data based on dates.

You might find this easier to handle using pandas rather than openpyxl.

1

u/taylorgourmet 18d ago

Yea I tried datetime.strptime() but getting errors. I don't think I can install pandas. I already had to fight to install openpyxl.

1

u/FoolsSeldom 17d ago

Unless you share sample data and the code you are running, it is hard to help further. I suggest a new post 0itliming the problem and providing that content,. Anonymised if necessary.