Automate Excel With Python - Python Excel Tutorial (OpenPyXL)

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ม.ค. 2025

ความคิดเห็น • 646

  • @TechWithTim
    @TechWithTim  3 ปีที่แล้ว +85

    Start a high paying tech career making $60k+/year with NO DEBT: coursecareers.com/a/techwithtim

    • @victor20214
      @victor20214 3 ปีที่แล้ว +1

      And support. Thanks tim

    • @realitynowassigned
      @realitynowassigned 3 ปีที่แล้ว

      What kind of keyboard are you using. I miss those clicks

    • @anandsharma2516
      @anandsharma2516 3 ปีที่แล้ว +2

      I think some bug is there not accepting the mobile number or land line no. with & without the city code and country code. Or a fake one

    • @ardit9988
      @ardit9988 3 ปีที่แล้ว

      🇬🇧🇽🇰🌟🌟

    • @Bart_Depestele
      @Bart_Depestele 3 ปีที่แล้ว

      Did you love yourself amigo? :)

  • @VladArnoldner
    @VladArnoldner 2 ปีที่แล้ว +31

    I am working as a Senior Financial Officer dealing with financial reporting. This video gives me a new powerful tool to quickly manipulate and process a large volume of data. I think I will surprize my boss with my new skills! Thank you, Tim!!!

    • @SwahiliSpicE
      @SwahiliSpicE 9 หลายเดือนก่อน +1

      I'm a tax accountant, this is exactly what I've been doing for the past couple of years. Bringing in so much value to the business, and plugging the cash leakages using coding skills, you get taken more seriously.

    • @thefitfrontier
      @thefitfrontier 7 หลายเดือนก่อน

      @@SwahiliSpicE the excel docs are created from your ide or within excel? seems VS code will not bring in excel file created in excel?

    • @martinkuliza
      @martinkuliza 5 หลายเดือนก่อน

      You can do the same thing if you use SQL except the SQL C.L.I. is going to be easier to bring up a sheet and view it entirely , You just use the SHOW command
      perhaps also look into that
      i reckon there's a time and place for SQL CLI
      and a time and place for Python with Excel
      Python as a programming tool is unbelievable , to do financial analytics , Sure.
      But someone has to write the script to achieve your goal
      Excel is also good for that as well as importing data from external websites and databases
      but python is certainly more powerful than excel
      so.. Time and place for everything

  • @NextManu
    @NextManu 2 ปีที่แล้ว +37

    recently got into learning python.
    my mind is blown with the versatility of python. I now wish i had done software engineering back in school..

  • @derekwest8636
    @derekwest8636 2 ปีที่แล้ว +22

    New to python and starting my own project working with excel files. Tried to go through the documentation for openpyxl and was wasting alot of time learning unnecessary information based on what I was trying to accomplish. You've done a wonderful job with this and I was able to easily follow along and experiment along the way. Put together a py file for my notes on this module. Tim is Great!

  • @boldtecmedia3003
    @boldtecmedia3003 3 ปีที่แล้ว +20

    exactly what i needed, im a civil engineer and learning python. i was coding a building cost estimator desktop app in tkinter and needed python after calculating all materials for me, it should also create an excel workbook and type those results for me. so that i simply print out for the client in the shortest time possible. awesome video. thank you sir.
    im a complete beginner though, any one with a better way of doing it is welcome

    • @tonyvelasquez6776
      @tonyvelasquez6776 3 ปีที่แล้ว

      Python is probably the best way to do that. I don't think you necessarily need tkinter though

    • @furkankilicaslan
      @furkankilicaslan 3 ปีที่แล้ว

      Hi, I am an industrial engineer and currenly looking for ways to automate the process of some report that we do in excel. tkinter might be a good idea for people that don't have the expertise or the knowledge of python cause they are just going to use the interface. hope you get what you want. Really appreciate if you reply the result if you finish the project. You should try KNIME too. Good luck. Cheers!

  • @chaitanyakolluri2839
    @chaitanyakolluri2839 3 ปีที่แล้ว +112

    Hands done one of the best Python training videos out there I’ve. Method of instruction, clarity and examples are brilliant. Thank you so much.

  • @lilrex2015
    @lilrex2015 2 ปีที่แล้ว +15

    This is quality stuff. This guy gets how to make a good tutorial video. No wasted time, points are explained enough to understand then moves on.

  • @gl4989
    @gl4989 3 ปีที่แล้ว +1228

    Boomers at my work will now treat me as a god

    • @salsabilahmedshrestho960
      @salsabilahmedshrestho960 3 ปีที่แล้ว +56

      I am at my final year, and just got to know about automation and how seniors don't know it. :v
      I also wanna feel how you said 😂

    • @girishbhoite264
      @girishbhoite264 3 ปีที่แล้ว +6

      🤣

    • @mienzillaz
      @mienzillaz 3 ปีที่แล้ว +27

      No, they won't

    • @videofandude99
      @videofandude99 3 ปีที่แล้ว +14

      for a quick minute until they start doing themselves to save their jobs

    • @Mr.Blumister
      @Mr.Blumister 3 ปีที่แล้ว +3

      Actually it is exactly like that! :D

  • @manndipp
    @manndipp 2 ปีที่แล้ว +2

    by far, the best video for starting excel with python

  • @TheNameIsForty
    @TheNameIsForty 3 ปีที่แล้ว +13

    Actually did something similar a month ago, where I converted the excel file in to base64 in the end and sent it through an API to then generate it back into xlsc format through typescript.
    PyXl is amazing btw, anyone who watches this should try it. Very easy to use.

  • @JourneeDecker
    @JourneeDecker ปีที่แล้ว +1

    Clear, rich, concise and well delivered. Thanks!. Clear, rich, concise and well delivered. Thanks!.

  • @addledanorak8297
    @addledanorak8297 3 ปีที่แล้ว +24

    Was waiting for such a vid for soooo looooong. Thx Tim :)

    • @UltraProbe
      @UltraProbe 3 ปีที่แล้ว +1

      Haha ikr. I learned a bit of Openpyxl for a script I run everyday, but this should let me do some more interesting stuff ;)

  • @pythonenthusiast9292
    @pythonenthusiast9292 3 ปีที่แล้ว +28

    to those who are thinking @6:52 that you can directly open the workbook or directly save the workbook using that load_workbook command.. no ppl.. you need to first make or upload a workbook at the location of your text editor or some random location then take that location from there .

  • @preisback24
    @preisback24 2 ปีที่แล้ว +4

    I've been learning Python by following a book and got confused and stuck for so long until I found this video. Thanks

  • @Global-Geographics
    @Global-Geographics หลายเดือนก่อน

    You are a life saver dear, the way you teach is the best

  • @omuk4584
    @omuk4584 2 ปีที่แล้ว +1

    Who the heck is this guy!! Just amazing trainings and super easy to follow along. Keep them coming Tim, much appreciated.

  • @sateeshum394
    @sateeshum394 13 วันที่ผ่านมา

    very well organized teaching methodology and great way of walking through.

  • @akankshc5707
    @akankshc5707 3 ปีที่แล้ว +1

    this is a whole another lvl. of automation with python

  • @CarlFritz24
    @CarlFritz24 2 ปีที่แล้ว

    AMAZING, Tim. The best demonstrated matter I have ever seen.

  • @roccov3614
    @roccov3614 3 ปีที่แล้ว +9

    As someone who loves Excel and is learning and loving python, I think this module is awesome.

    • @CrypticConsole
      @CrypticConsole 3 ปีที่แล้ว

      Than look at pandas

    • @roccov3614
      @roccov3614 3 ปีที่แล้ว

      @@CrypticConsole I new pandas dealt with data. I didn't know it could access Excel docs. Thanks.

  • @dmitryg9613
    @dmitryg9613 2 ปีที่แล้ว +1

    man, I really appreciate your work and time spent on explanation. I would never sort it out without your help

  • @sandragraham8289
    @sandragraham8289 9 หลายเดือนก่อน

    This strategy is bomb!!! I won 3/4 just testing it out!!! Thank you for sharing!!

  • @jewelsoncagakit8423
    @jewelsoncagakit8423 ปีที่แล้ว

    Wow ! All the basic fundamentals are packed in one demo ! Thanks Tim !

  • @MrSuspicious0
    @MrSuspicious0 3 ปีที่แล้ว +96

    For anyone like me who finds the lettering system tedious and annoying, rather than using the get column letter function you can just use sheet.cell(1,1) for example which would be cell A1, but I think this is nicer especially if youre using nested for loops.

    • @ignoble_hierarch
      @ignoble_hierarch 2 ปีที่แล้ว +5

      Thank you! So, to stick more to the tutorial, it will be like *ws.cell(1, 1).value = "Type something"*.
      By the way, you have a similar reference system in VBA as well.

    • @PolytecGuy91
      @PolytecGuy91 2 ปีที่แล้ว +12

      thats the way to handle columns greater than "26" also.

    • @dbdejonge2081
      @dbdejonge2081 29 วันที่ผ่านมา

      Char(64+column number)

  • @relhage100
    @relhage100 3 ปีที่แล้ว +7

    Clear, rich, concise and well delivered. Thanks!

  • @stevemorse5052
    @stevemorse5052 2 ปีที่แล้ว +4

    As Tim noted, you cannot save the spreadsheet changes if it is opened in Excel (or in my case, Libre Office) for 'normal' use.
    I did figure a sort of workaround to this problem.
    If you open the spreadsheet as read only, your python code will run without a problem. Now to view the changes simply reload the spreadsheet.
    The reload command in Libre Office can be found under File >>> Reload (or press the keys Alt, f, l in that order(Note l is lowercase L))
    Yes, you have to remember to reload the spreadsheet every time you make a change, but it is quicker than the close, reopen way, you could put a reminder in your python code.
    Note, if you want to edit the read only open file, there is a button on the top right that says Edit Document. but remember after editing it needs to be saved and reopened as read only.
    Use the python command try when doing a workbook save, and if it throws and exception, then ask the user to go through the close/reopen read only routine.

  • @simoneriksson548
    @simoneriksson548 3 ปีที่แล้ว +4

    Awesome video Tim! Ive struggled a bit with python and definently had some 'aha!' oments watching this! Keep up the good work!

  • @MaxRuso
    @MaxRuso 2 ปีที่แล้ว

    the posibilities and list of errors is so good as it helps

  • @aungphyo9237
    @aungphyo9237 10 หลายเดือนก่อน

    The best video about openpyxl. It is helpful for me a lot.

  • @Mr.Blumister
    @Mr.Blumister 3 ปีที่แล้ว

    Bruh! You literally made me safe countless hours of work at my job! Lovin' it

    • @TechWithTim
      @TechWithTim  3 ปีที่แล้ว +1

      Glad I could help!

  • @ianbraganza3065
    @ianbraganza3065 3 ปีที่แล้ว +2

    Thanks for a great video. It helped me automate several redundant tasks and opened my mind to the power of openpyxl

  • @duzyolek
    @duzyolek 3 ปีที่แล้ว +2

    I started the transition from VBA to python+OpenPyXL around 2 weeks ago (after years of experience with VBA) and there it is - Tim's video about this very topic!

    • @micheleluigimelis426
      @micheleluigimelis426 3 ปีที่แล้ว +4

      Why did you decide to change? What are the benefits of using Python in this case?

    • @Bayo106
      @Bayo106 3 ปีที่แล้ว

      @@micheleluigimelis426 way less code

    • @haroldgamarra7175
      @haroldgamarra7175 ปีที่แล้ว

      @@Bayo106 not having to declare variables to begin.

    • @deninsrmic4165
      @deninsrmic4165 27 วันที่ผ่านมา

      @@Bayo106and less intelligible than Visual Basic, I accomplishes so much via VBA in all Microsoft applications, disliked python syntax from day one but being coerced to learn it due to job requirements. I am still on the learning path and still like visual basic syntax more.

  • @titojulyharyanto3397
    @titojulyharyanto3397 ปีที่แล้ว

    Thank you so much Tim for sharing this. God bless you and all the best for you

  • @deanlawson6880
    @deanlawson6880 2 ปีที่แล้ว +1

    Excellent run-through of this. Very cool to be able to interact with Excel spreadsheets in Python!
    Thanks for this - Nicely done!

    • @scoopiezz
      @scoopiezz ปีที่แล้ว

      i liked ur comment cause it had no likes. It a lonely comment

  • @nickyfranshel1210
    @nickyfranshel1210 3 ปีที่แล้ว +10

    pains of suffering of reading stackoverflow of excel automation and alien language has come to an end 😌

  • @rishabhtripathi593
    @rishabhtripathi593 9 หลายเดือนก่อน

    Thank you for this, it helped me a lot for an college assignment
    < 3

  • @Kitejrpaladin
    @Kitejrpaladin 3 ปีที่แล้ว +14

    For anyone reading there are random real-world use-cases for stuff like this on occasion, I recently did something similar with Word and Powershell. In my case, I would take data from a CSV and generate a document containing stuff like login information, Employee IDs, etc. It can save time when you are doing 25+ of these documents.

    • @michaelmessiha1281
      @michaelmessiha1281 2 ปีที่แล้ว

      why powershell?

    • @davewiebe2582
      @davewiebe2582 2 ปีที่แล้ว

      I use powershell alot, it does alot of the same things python does and it's integrated into the OS

    • @Kitejrpaladin
      @Kitejrpaladin 2 ปีที่แล้ว +1

      Pretty much for the reasons Dave described. When in Rome, do as the Romans do.
      For general purpose stuff like this in Windows environments, PowerShell is the better tool for the job, not because it's better than Python or anything silly like that but because it's the lingua franca of Windows and has plenty of cmdlets to deal with the tasks you'll run into in a Windows environment but just as importantly the people I work with have a better chance of understanding my code if it's in PowerShell vs Python.
      For a more specialized task maybe I dip into the .Net APIs using PowerShell (use the native PowerShell solution first as best practice) or pull out C# in a Windows Environment.
      To choose an example where I would definitely prefer Python is anything in the Data Analytics or Machine learning world.
      On the operations side if you ever need to deal with networking equipment, the community has built some really good libraries for automating working with routers and switches. Network Automation and SDNs are a thriving space in Python.
      I actually tooled around with some Unifi stuff in Python while trying to automate performing resets of multiple Unifi Access Points. (Didn't really work out but learned a bit)

  • @hubertkarwowski1646
    @hubertkarwowski1646 3 ปีที่แล้ว

    The best tutorial video about python excel I have ever seen $.$

  • @joeyzalman8254
    @joeyzalman8254 2 ปีที่แล้ว +3

    very clear thank you!

  • @MassimoCLI
    @MassimoCLI 4 หลายเดือนก่อน

    Congrats, great presentation. Got very interesting points. thanks

  • @strydomobile
    @strydomobile 3 ปีที่แล้ว +1

    You are really talented in carrying information across. Thanks for this video.

    • @TechWithTim
      @TechWithTim  3 ปีที่แล้ว

      Appreciate the comment :)

  • @123456789mumbai
    @123456789mumbai 2 ปีที่แล้ว

    Thanks you so much for explaining in so detail and easiest way. Thanks a lot ❤

  • @inspired4more
    @inspired4more ปีที่แล้ว +3

    I love Python, but Excel already has VBScript built in. In my work, I haven't had many cases where the python add in was more useful than writing my own macros in VBScript. It's not all that hard a language to learn anyway.

  • @tenshi_tries
    @tenshi_tries 3 ปีที่แล้ว +1

    I have a work that recently needed this--- JUST IN TIME! thank youu

    • @Salmankhan-qt8uy
      @Salmankhan-qt8uy 3 ปีที่แล้ว

      Can u help me with the scenario u have in ur work. Thanks

  • @realitynowassigned
    @realitynowassigned 3 ปีที่แล้ว +1

    Thank you for the install error explanations. Thats something most videos lack

  • @topfundus1093
    @topfundus1093 3 ปีที่แล้ว +2

    Sehr gut! Danke! Viele Grüße aus Deutschland!

  • @shinichi9do
    @shinichi9do 3 ปีที่แล้ว +1

    Crystal clear. Thank you.

  • @hemalpatel9708
    @hemalpatel9708 2 ปีที่แล้ว

    It helped for creating ustom excel file from python! Thanks a lot

  • @tridibbiswas3361
    @tridibbiswas3361 3 ปีที่แล้ว +19

    Thank you Tim for the video. Its helpful for people like are in the process of picking up the rudiments of python. Could you do a video about OpenPyXL + Pandas. How these two work together and what are the pros and cons of using openpyxl and pandas on their own

  • @expat2010
    @expat2010 ปีที่แล้ว +3

    This is a good example of why I love Python even more than VBA. It is so intuitive and readable compared to most other languages.

  • @oliesting4921
    @oliesting4921 3 ปีที่แล้ว +6

    Awesome, was searching for this. Next up, extract data from table in a PDF file, please :)

    • @notyaniecetv
      @notyaniecetv 3 ปีที่แล้ว

      Oooh yes!!

    • @romanval69
      @romanval69 3 ปีที่แล้ว

      The python package "Camelot" can already do this.

  • @Вавилон-й5у
    @Вавилон-й5у 2 ปีที่แล้ว

    dude. this is sooooooo helpful, thank you

  • @e555t66
    @e555t66 2 ปีที่แล้ว

    Fastest way to get started. Let's go.

  • @unpatel1
    @unpatel1 3 ปีที่แล้ว +1

    Thank you for this great intro!!

  • @DevGuedes
    @DevGuedes 3 ปีที่แล้ว

    I'm From Brazil!!!!! Perfect Video!!!!

  • @blackchristiangeek
    @blackchristiangeek 2 ปีที่แล้ว +1

    Awesome tutorial and my only frustration is time limitations to apply all that you have shared. Thanks, and God bless

  • @haikamu7178
    @haikamu7178 2 ปีที่แล้ว

    Very good, now i'm not tired for some accounting work.

  • @kychemclass5850
    @kychemclass5850 3 ปีที่แล้ว +10

    Tim. Could you do an equivalent video Automating LibreOffice Calc ?? It would be fantastic. I'd even give a reasonable financially contribution for the effort.

  • @someone...000
    @someone...000 ปีที่แล้ว +2

    I expected this to be as easy as working with the csv module, but obviously it isnt, and now that i think about it, why would it be. Nevertheless, this video help me understand it even more than i understand the csv module, from installing OpenPyXL, to formulas and cell styling. Great video Tim! Thanks for all that you do for us python noobies☺

  • @bujeshm3736
    @bujeshm3736 หลายเดือนก่อน

    Thank you brother ❤❤❤

  • @cantwaitforit
    @cantwaitforit 3 ปีที่แล้ว

    Cool video! I didn't think that it is so easy(thanks man who make this library). After this video, it's obligatory to subscribe.

  • @sharongur64
    @sharongur64 ปีที่แล้ว

    Most educational thank you Tim !

  • @cabechomp
    @cabechomp 2 ปีที่แล้ว

    Great video, it helped me a lot with a project that i have and i only knew how to work with CSV files that didnt helped me at all. Thank you

  • @robertlaplante8812
    @robertlaplante8812 2 ปีที่แล้ว

    Great video! It helped me a lot starting in Python! Many thanks!

  • @Mario3cush
    @Mario3cush 3 ปีที่แล้ว +2

    Great video. Super useful. Thanks, Tim!

  • @KaosDragonLOC
    @KaosDragonLOC ปีที่แล้ว

    I loved the video and would love a tutorial doing the reverse of the last project showing how to take a workbook and use that information to create a dictionary out of it

  • @dlo009
    @dlo009 3 ปีที่แล้ว

    Thks for the intro. Great vid.

  • @MrJonas1995
    @MrJonas1995 ปีที่แล้ว

    Great video! Well explained!

  • @murilosilvestre7736
    @murilosilvestre7736 3 ปีที่แล้ว

    This video was a blessing to me, Thanks very much!

  • @lionelnishan5623
    @lionelnishan5623 ปีที่แล้ว +4

    Great Tutorial Tim :)
    one suggestion: To open the excel file you created or working on, instead of going to the designated folder and find the file, you can just open it from the project tree.

  • @rostamr4096
    @rostamr4096 ปีที่แล้ว

    wow...this is so very helpful...Thank you

  • @berghoutcful
    @berghoutcful 3 ปีที่แล้ว +1

    Great work! Thank you for this! Subscribed!

  • @sinaalizadeh1
    @sinaalizadeh1 2 ปีที่แล้ว

    Thank you for your great explanations ❤️

  • @thinula5635
    @thinula5635 3 ปีที่แล้ว

    Best tutorial about Excel automation. Thanks, Sir

    • @1991gsn
      @1991gsn 3 ปีที่แล้ว

      That now kinda useless with power automate desktop built in windows 10/11

  • @zukofire6424
    @zukofire6424 2 ปีที่แล้ว +2

    this was very helpful for my internship (at a messy start up)! Thank you so much Tim!!

  • @capincrunch1184
    @capincrunch1184 3 ปีที่แล้ว

    Bruhhhh needed a video like this 4 months ago

  • @Balgalw
    @Balgalw 2 ปีที่แล้ว

    Tim, thanks a lot for detailed video. Simply the best way to use Excel formulas with get_column_letter, can't figure it out myself

  • @AnilKumar-bh4vt
    @AnilKumar-bh4vt 3 ปีที่แล้ว +2

    Using python for sheets is very helpful,I use it on a regular basis

  • @vigneshsrinivasan3914
    @vigneshsrinivasan3914 2 ปีที่แล้ว

    Great work. Good to get started.

  • @forzahorizon4eliminator206
    @forzahorizon4eliminator206 ปีที่แล้ว

    thanks i will come back for more i need to watch the full video. but yes i admit you helped me with what i wanted thanks brother

  • @Chris_AR1
    @Chris_AR1 2 ปีที่แล้ว

    Nice video! Great for a beginner to get comfortable with Python and Excel

  • @mrtyecee
    @mrtyecee 2 ปีที่แล้ว +2

    Your videos are straight 🔥🔥🔥🔥 as a programming newbie I'm learning alot from you. Thanks for all you do!

  • @joen5000
    @joen5000 3 ปีที่แล้ว +5

    A very good video. Thanks Tim.
    I think that you could have saved some time in this video, if you would have added a close, open excel file function within the Python code, and would have called it up each time you test your code. That way, it would close that particular file, save it and reopen it automatically without you needing to do it manually, as you did in this amazing video.
    Lemogan

    • @nocodenoblunder6672
      @nocodenoblunder6672 3 ปีที่แล้ว +1

      Opening a file is easy obv but dont know how you close a file cause once its open the application itself is usually responsible for this

  • @PerezMuñozFernando
    @PerezMuñozFernando 4 หลายเดือนก่อน

    Thx Tim!

  • @diminati8659
    @diminati8659 3 ปีที่แล้ว +1

    As usual, very useful. Thank you!

  • @alangodoy9591
    @alangodoy9591 3 ปีที่แล้ว

    the master has spoken

  • @Mio-ev2iz
    @Mio-ev2iz ปีที่แล้ว

    Thank u so much for the video!

  • @johannesperez9548
    @johannesperez9548 3 ปีที่แล้ว

    This is great! Thanks for sharing!

  • @khytron06
    @khytron06 3 ปีที่แล้ว +1

    19:00 why not just do
    for row in range(1, 11):
    for col in "ABCD":
    print(ws[col + str(row)].value)

  • @mayiraahmat1005
    @mayiraahmat1005 3 ปีที่แล้ว

    Thank you so much 👍👍👍👍🌟🌟🌟🌟

  • @eshanwijetunge2518
    @eshanwijetunge2518 3 ปีที่แล้ว

    Thank you for your Great Session

  • @bbulliard
    @bbulliard ปีที่แล้ว

    Well done. Thanks. Bob

  • @vuho4668
    @vuho4668 7 หลายเดือนก่อน

    Thank for vid. Its help me alot

  • @VredesbyrdNoir
    @VredesbyrdNoir 3 ปีที่แล้ว +2

    Man, you can do a lot of sheet with Python these days!

  • @milesgardner9988
    @milesgardner9988 3 ปีที่แล้ว

    Wow. Thank you so so much for this.

  • @vandrujemesk8651
    @vandrujemesk8651 2 ปีที่แล้ว

    Thanks, super video tutorial.

  • @ahmedsoliman779
    @ahmedsoliman779 2 ปีที่แล้ว

    Amazing Work

  • @startjourney8631
    @startjourney8631 3 ปีที่แล้ว

    Am your new subscriber 🤝✨♥️your content and presentation style is 😘👌

  • @noob_dos_dados
    @noob_dos_dados 3 ปีที่แล้ว

    Thanks for your video, you helped me a lot in my work :)

  • @pyvfx
    @pyvfx 3 ปีที่แล้ว

    tnks tim its very helpfull for me.
    lov u man