Automate Excel using Python | Excel Hacks with Pandas

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ต.ค. 2024
  • This video is about Excel Hacks with Pandas, automate Excel using python and how to split an excel file into multiple sheets. Also learn to excel hacks 2019
    Here is the code on github: github.com/sat...
    👉 Patreon: patreon.com/SATSifaction
    👉 Facebook Group: / theaiwarriors
    👉 Instagram: @theaiwarriors
    👉 Corporate Training and Up skilling: levers.ai
    Netfirms (Affiliate) - bit.ly/2KdJ4Dp
    Linode Server - bit.ly/2XpqGi9
    Bluehost (Affiliate) - bit.ly/2GxxBh1
    PythonAnywhere (Affiliate) - bit.ly/2kWORVe
    Heroku - www.heroku.co
    NordVPN (Affiliate) - bit.ly/2W87je0
    Here is a link to my python for beginners, master python course: bit.ly/2HIZS42
    Favourite Mobile Apps to Run Python and Code
    iOS - Pythonista (paid) - apple.co/2HjRVTJ
    Android - Dcoder (free) - bit.ly/2Vrjb6N
    Song
    Credit To Author
    Support Cavardix Beats:
    / cavardix
    / cavardixbeats
    / cavardixbeats
    www.youtube.co....
    -----------------------------------------------------------------
    Royalty Free Music - Shadows (Dark Underground Rap Beat Hip Hop Instrumental)
    • Video

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

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

    Coming from a business background, found myself in a situation at work where I can use excel/python to transform our processes - wish me luck!

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

    For those of you asking: YES it can be done with the native Excel tools. Nevertheless, tutorials like this one are great for adding new tools to our toolbox, for certain things some programming languages are simply better suited than others, it's good to have more than 1 weapon in your arsenal.
    Two ways to solve this natively:
    a) If the categories are not too many, a quick pivot table with anything as values and all the categories as rows will do the trick. Simply double-click in the subtotal for each row and a new sheet will be created with all the table rows pertaining to the specific division only. Rename the sheet and it's done
    b) VBA, you can use something like the following macro to get it done, it prompts for the user to provide the table range (including headers) as well as for the user to provide the column to be used as categories (as a string input). You can modify the code if you feel like, it's a bit sloppy but it will do the job.
    Sub splitBy()
    Dim table, header, colHeader, activeItem, activeRow As Range
    Dim field As String
    Dim nTimes, currentRow As Long
    Dim sht As Worksheet
    Set table = Application.InputBox(Prompt:="Select the table including headers", Type:=8)
    field = Application.InputBox(Prompt:="Input column name", Type:=2)
    Application.ScreenUpdating = False
    nCols = table.Columns.Count
    nRows = table.Rows.Count - 1
    Set header = table.Resize(1, nCols)
    Set colHeader = header.Find(field)
    table.Sort key1:=colHeader, order1:=xlAscending, header:=xlYes
    currentRow = 1
    Do While currentRow

  • @KleanthisSkoulikaris
    @KleanthisSkoulikaris 5 ปีที่แล้ว +35

    Dude, you’re a GOD! I just stumbled across your videos recently and I love your Excel/Pandas/SQL videos. If I study your code carefully, I could potentially adjust it and use it in my work as well, where I often have to run similar scenarios.
    You got yourself a new dedicated subscriber!

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

      Thank you 🙏

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

      @@SATSifaction th-cam.com/video/Jg6g6foHzCs/w-d-xo.html
      #TenaliRK #FreeHinduTemples

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

    Excellent job!! I wrote a program pretty much exactly like this for a back end batch process that just dumped to a staging table in the morning. All the execs wanted to view it by market, division, and location type so I had to do a couple of groupbys in pandas on a few more columns. Nice to know I am not the only one building little tools like this for work that save so much time lol.

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

    That’s a great video. Kindly show us how you schedule the split excel emailed to concerned owner. That will be really useful and thanks for sharing the knowledge. Your videos boast up the confidence. 🙂

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

    Awesome, thank you! Although I would suggest casting the sheet names to strings, as I ran into type errors while trying out your script. But the rest was spot-on!

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

    Love the video. This is my first of many videos, I want to watch to improve me using Python for Excel. Quick question though, if I wanted to sort the sheets alphabetically, where would I insert that? The column segmentation I have has 20 columns and they are all out of order. I plan on watching more of your videos later today. Thank you.

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

    Nice work clearly explained! If we are using pandas then it would be easier to use the groupby function in pandas!

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

    This was really helpful. Thanks a lot !!

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

    Gonna do this for my dropshipping report...

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

      what product did u do for dropshipping?

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

    This is nice but you can do this with a few lines in VBA.

    • @sniper6219
      @sniper6219 4 ปีที่แล้ว

      how so? wouldnt mind seeing it in vba too! thanks!

    • @jcventura8532
      @jcventura8532 4 ปีที่แล้ว

      @@sniper6219 You can refer to my comment. Cheers!

  • @maxbart1353
    @maxbart1353 4 ปีที่แล้ว

    i just wanna thank you for your code and your videos

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

    Not able to download code from GitHub. Can u help me with the code.
    Thanks in advance., 🙏

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

    Great video. Thanks so much.

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

    The technique used will also affect the runtime. If u try to filter and split, instead of per cell check, it will greatly improve the runtime

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

      How would you modify it to add for filter and split instead? Curious, because I work with 300-660k row files and that could take a while.

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

    what is the point for the first (while True ) in the last cell , and thankyou

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

    I used to to this kind of tasks with VBA. I've started learning python and I love it, however, is there any advantadge of using python instead of VBA? I find that splitting data with the advanced filter function in Excel is already a very efficient way

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

      Good question. When you think of python think about scaling. VBA in this context is very limited to the workbook you are in. Python enables you to scale by integrating into other platforms with your excel notebook like pure machine learning frameworks, web dev etc. VBA is not scalable like python is.

    • @RalphNgOfficial
      @RalphNgOfficial 4 ปีที่แล้ว

      Excel has a limit in number of rows, it cannot be more than 1 million rows,
      If u are handling less data, u can stick back to Excel
      If u are handling data like more than 1 million of rows, let's consider using Python

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

      I have used VBA for long time. Now I'm using Python and I love it. However, for this kind of "Office Task" it is less time consuming and more convenient using VBA. This is not about ML or AI at all, it's Application oriented script and VBA's been done for it. Reinventing the wheel, making up the process longer or just making it as a "nice-to-have" tool is not ideal

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

    Hi Sir, this is what exactly i was looking for but finaly i found in your channel, thnak you for making this video.
    i am not able to open code.
    when i click on the link in discription Git hub says
    "Uploads are disabled.
    File uploads require push access to this repository."
    please help

  • @jonathanfriz4410
    @jonathanfriz4410 4 ปีที่แล้ว

    Thanks man, very clear. Also thanks for sharing. One doubt. The file merge follow some order for dates of that instance? or is all of the first category then all the second category and so on? of course you can sort it later on excel.

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

    Hey man, good tut, but please zoom in/increase text size next time. Can hardly read anything.

  • @Bubbles-qh7ez
    @Bubbles-qh7ez 3 ปีที่แล้ว +1

    This is great. thank you!

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

    amazing stuff.. your videos deserve more views.

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

    Hey, is it possible to keep the formulas when spliting to new files?

  • @LM-ou3kc
    @LM-ou3kc 3 ปีที่แล้ว

    Why wasn’t the export filtered with a “WHERE “ clause?

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

    Why are there two for loops in the sendtosheet function?

  • @BekBrace
    @BekBrace 4 ปีที่แล้ว

    That was very useful, thank you sir

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

    showing an error "expected string or bytes-like object" do you guys know why?

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

    I did not understand the need for nested for loop for send to sheet function. I rewrote the code like below and it still works. Can someone tell me why we had nested for loops for the same ?
    def senttosheet(cols):
    copyfile(file, newfile)
    writer=pd.ExcelWriter(newfile,engine='openpyxl')
    #for j in cols:
    for myname in cols:
    mydf = df.loc[df[colpick] == myname]
    mydf.to_excel(writer, sheet_name=myname, index=False)
    writer.save()
    print("Completed successfully")
    return

  • @karunakaransabapathy9617
    @karunakaransabapathy9617 4 ปีที่แล้ว

    Its very useful but not working for me getting invalided argument while giving input file.

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

    Great video.

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

    Where u wrote this script Visual studio or spider platform.

    • @SATSifaction
      @SATSifaction  4 ปีที่แล้ว

      this one i believe was pycharm tho I've since moved to sublime

  • @mtgmtgyoutube221
    @mtgmtgyoutube221 4 ปีที่แล้ว

    Thanks a lot for sharing!!

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

    great video, how to combine multi excel file with multi sheets

  • @jariuslouie
    @jariuslouie 4 ปีที่แล้ว

    New subscriber here. Thanks for all these amazing content that you have.

    • @SATSifaction
      @SATSifaction  4 ปีที่แล้ว

      JL you’re welcome

    • @jariuslouie
      @jariuslouie 4 ปีที่แล้ว

      @@SATSifaction Complete newb question here but I cant get past the part where I enter the file path. The error text below keeps popping up:
      IndexError Traceback (most recent call last)
      in
      4 pth=os.path.dirname(file)
      5 newfile=os.path.join(pth,filename+'_2'+extension)
      ----> 6 df=pd.read_excel(file)
      7 colpick=input('Select Column: ')
      8 cols=list(set(df[colpick].values))
      C:\Anaconda3\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
      206 else:
      207 kwargs[new_arg_name] = new_arg_value
      --> 208 return func(*args, **kwargs)
      209
      210 return wrapper
      C:\Anaconda3\lib\site-packages\pandas\io\excel\_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, verbose, parse_dates, date_parser, thousands, comment, skip_footer, skipfooter, convert_float, mangle_dupe_cols, **kwds)
      338 convert_float=convert_float,
      339 mangle_dupe_cols=mangle_dupe_cols,
      --> 340 **kwds
      341 )
      342
      C:\Anaconda3\lib\site-packages\pandas\io\excel\_base.py in parse(self, sheet_name, header, names, index_col, usecols, squeeze, converters, true_values, false_values, skiprows, nrows, na_values, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols, **kwds)
      881 convert_float=convert_float,
      882 mangle_dupe_cols=mangle_dupe_cols,
      --> 883 **kwds
      884 )
      885
      C:\Anaconda3\lib\site-packages\pandas\io\excel\_base.py in parse(self, sheet_name, header, names, index_col, usecols, squeeze, dtype, true_values, false_values, skiprows, nrows, na_values, verbose, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols, **kwds)
      440 sheet = self.get_sheet_by_name(asheetname)
      441 else: # assume an integer if not a string
      --> 442 sheet = self.get_sheet_by_index(asheetname)
      443
      444 data = self.get_sheet_data(sheet, convert_float)
      C:\Anaconda3\lib\site-packages\pandas\io\excel\_xlrd.py in get_sheet_by_index(self, index)
      44
      45 def get_sheet_by_index(self, index):
      ---> 46 return self.book.sheet_by_index(index)
      47
      48 def get_sheet_data(self, sheet, convert_float):
      C:\Anaconda3\lib\site-packages\xlrd\book.py in sheet_by_index(self, sheetx)
      464 :returns: A :class:`~xlrd.sheet.Sheet`.
      465 """
      --> 466 return self._sheet_list[sheetx] or self.get_sheet(sheetx)
      467
      468 def sheet_by_name(self, sheet_name):
      IndexError: list index out of range

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

    Thanks for the inspiring and useful video! I appreciate you share the information on how to setup these pips as I did all action described in the video, however after I run the split script it says that pandas is not found. I have updated Python to 3.7.6 version on a Mojave OS.

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

      Glad you liked it

    • @mishaisgifted
      @mishaisgifted 4 ปีที่แล้ว

      @@SATSifaction sorry, I didn't type all info. So just updated the comment with a question. Appreciate the link on basic packages I need to run the script described in this video. Sorry for such noob request, I would say I almost zero in coding, but advanced in excel.

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

      No problem. That generally means pandas is not installed properly. You can try to uninstall it and reinstall it. Alternately you can set up a virtual environment and run it all in there. It will work without issue if you run it in a virtual environment. Try this video 👉🏻 How to use a Python Virtual Environment the RIGHT way with Jupyter Notebook

    • @mishaisgifted
      @mishaisgifted 4 ปีที่แล้ว

      @@SATSifaction thanks! Will dig into that!

  • @YashovardhanSinghRajput
    @YashovardhanSinghRajput 4 ปีที่แล้ว

    It's Awesome Loved it

  • @rednax25
    @rednax25 4 ปีที่แล้ว

    Hi There. Great Tutorial. However if I use Atom editor to run this program I get this error after the file path is entered: Alexanders-Air:Excel_Splitter_Combiner-master lexi$ python combinefiles.py
    File Path: /Users/lexi/Downloads/Excel_Splitter_Combiner-master/N_Power_Split_Data/
    Traceback (most recent call last):
    File "combinefiles.py", line 5, in
    file=input('File Path: ')
    File "", line 1
    /Users/lexi/Downloads/Excel_Splitter_Combiner-master/N_Power_Split_Data/
    ^
    SyntaxError: invalid syntax
    In Jupyter notebook it works well, just cant find a way to get the combined excel out.
    Please help.

  • @saibalbiswas952
    @saibalbiswas952 4 ปีที่แล้ว

    thanks for sharing.. i am not able to find the combined file ...

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

    Love it!!

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

    so any good resources on when there are : and & in the column titles and the Segment data?
    Thanks!

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

      After a little playing around I just realized that I cannot use \ / * [ ] : ? in sheet names or file names... ...which does make sense... out of our database we have : identifying parts... so i need a way to change this in the sheet before splitting....

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

      okay so been fighting with this for a little while... ...does anyone know how to remove the special characters before the split?

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

      You can always use a replace command to remove special characters. You can either replace special characters with an underscore which I believe is acceptable in excel or just remove it all together. There are ways to do this is code with python by using a str.replace (‘old’, ‘new’) command or you can do it a replace within excel.....so you can easily pull the data from your DB into python and use the replace method. There are more sophisticated ways of doing this with NLP as well....a quick google search on the above should set you in the right direction.

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

    it would be great if explain the code inside the .py files.

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

      Hi Darwin, if you watch towards to the end of the video I explain the .py file

  • @BrettKromkamp
    @BrettKromkamp 5 ปีที่แล้ว

    Useful tutorial!

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

    while executing the splitfile the last part of the code gives an error saying "TypeError: sequence item 2: expected str instance, float found" kindly help.

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

      Means that is found a number (int) and was expecting a string (text)

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

      You can potentially solve this by finding the "sequence item 2" the error references and try to cast the float as a string using "(str)sequence_item_2" for example. This will force the float value to become a string in the scope of wherever you cast it. Hope this helps!

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

      @@phantasm3207 Be aware that float and int are two very different data types. This comment is still valid in explanation albeit slightly flawed in accuracy. Great tips tho!

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

    Is it same process for PC?

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

      Yes it should be. Python is agnostic of OS

  • @Proviper666
    @Proviper666 4 ปีที่แล้ว

    Your git hub link is kinda messed up!

  • @camarojay7027
    @camarojay7027 4 ปีที่แล้ว

    Do you have a Python class for beginners?

    • @SATSifaction
      @SATSifaction  4 ปีที่แล้ว

      Yes of course check it out 👉 Master Python: Complete Beginners Course - th-cam.com/play/PLM30lSIwxWOijsnA2Fr1PPGkOiCaDaRod.html

  • @ayeshasamad8121
    @ayeshasamad8121 4 ปีที่แล้ว

    is it also for beginner with no programming knowledge ?

    • @SATSifaction
      @SATSifaction  4 ปีที่แล้ว

      You should probably understand the basics before jumping in. Check out my beginner python tutorial

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

    Amazing work. just A fan passing through. xD

  • @RalphNgOfficial
    @RalphNgOfficial 4 ปีที่แล้ว

    Could u please share the sample Excel file?

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

    Where's the code!?

  • @Debraj1978
    @Debraj1978 4 ปีที่แล้ว

    You do not sound like "Sahitya Sehgal".

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

    This is a great tutorial! Got a sub in me now :D
    Is there a link for that excel file for us to follow along? Don't see it on your Github

    • @SATSifaction
      @SATSifaction  4 ปีที่แล้ว

      Thanks and appreciate the sub. As for the file if I’m quite honest that was posted a while back and I dont have it on my computer anymore. I thought i had uploaded it with the other files but i didnt unfortunately. My tutorials are now triple checked for the original files :) sorry about that

  • @edgarsan71991
    @edgarsan71991 4 ปีที่แล้ว

    But with PBI it’s easier to do

  • @vishavgupta3717
    @vishavgupta3717 4 ปีที่แล้ว

    Please answer as soon as possible.I want your help.How to append pandas dataframe below an existing Excel file with the help of any library other than openpyxl. I have used openpyxl but openpyxl removes pivot table from my excel sheet. Please provide me code .How to achieve it?

    • @SATSifaction
      @SATSifaction  4 ปีที่แล้ว

      You would need to use something like df.loc[-1] to find the last row in your excel file and start the writing process from there. My advise is to import the data as a df and append it within python and write back to excel as a new tab. If you have too many rows then i'd consider a database like sqlite3 where appending the data is easier

  • @Vision267
    @Vision267 4 ปีที่แล้ว

    Cannot macro be used to do the same

    • @infared14
      @infared14 4 ปีที่แล้ว

      Yes, you can do this with VBA

    • @Vision267
      @Vision267 4 ปีที่แล้ว

      Which is the easiest

    • @infared14
      @infared14 4 ปีที่แล้ว

      @@Vision267 The same really. But Python gives you more options

    • @Vision267
      @Vision267 4 ปีที่แล้ว

      @@infared14 what kind of additional options

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

    i don´t understand all at the moment, but i hope to get a job with this knowledge

  • @nqtradingstrategies3107
    @nqtradingstrategies3107 4 ปีที่แล้ว

    👌

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

    nice one! However, I am not able to find the code in the github link metnioned above : github.com/satssehgal/Excel_S...

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

    Thanks for sharing, though the GitHub link missed the source code. I've made my own repository based on your code shown in the video. The link github.com/kailichou/SplitExcelbyColumnValue. Kudos to you.

    • @joey5069
      @joey5069 4 ปีที่แล้ว

      can you help me? I get the error: Traceback (most recent call last):
      File "split.py", line 42, in
      print("Your data will split based on these values {} and create {} files or sheets based on next selection. If you are ready to proceed please type 'Y' and hit enter. Hit 'N' to exit".format(', '.join(cols), len(cols)))
      TypeError: sequence item 0: expected str instance, float found

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

      @@joey5069 Hi, please change join(cols) into join(str(cols)) in your line 42.
      Thanks for letting me know. I already changed that in my github as well.

    • @joey5069
      @joey5069 4 ปีที่แล้ว

      @@learnmandarinwithkaili1102 thank you! I still learning python and I could not figure out why it was not workin. How did you find the problem?

    • @joey5069
      @joey5069 4 ปีที่แล้ว

      @@learnmandarinwithkaili1102 I get another error in the "split into files or sheets:
      Traceback (most recent call last):
      File "split.py", line 54, in
      sendTofile(cols)
      File "split.py", line 26, in sendTofile
      df[df[colpick]==i].to_excel("{}/{}.xlsx".format(pth, i), sheet_name=i, index=False)
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/core/generic.py", line 2175, in to_excel
      formatter.write(
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/formats/excel.py", line 730, in write
      writer.write_cells(
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/io/excel/_xlsxwriter.py", line 206, in write_cells
      wks = self.book.add_worksheet(sheet_name)
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xlsxwriter/workbook.py", line 180, in add_worksheet
      return self._add_sheet(name, worksheet_class=worksheet_class)
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xlsxwriter/workbook.py", line 729, in _add_sheet
      name = self._check_sheetname(name, isinstance(worksheet, Chartsheet))
      File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xlsxwriter/workbook.py", line 777, in _check_sheetname
      if len(sheetname) > 31:
      TypeError: object of type 'float' has no len()

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

      @@joey5069 would you mind to leave your questions at my repository? Would help others who run into the same bug.

  • @danielszalok8540
    @danielszalok8540 4 ปีที่แล้ว

    Okay, but why use python for such an easy task? VBA is much faster.

    • @SATSifaction
      @SATSifaction  4 ปีที่แล้ว

      Speaking from someone who has used both quite extensively in my career what I want to emphasize isnt just for this specific task but the automation integrations and trigger points that python offers with something like this...., its unmatched and much more superior than VBA.

    • @danielszalok8540
      @danielszalok8540 4 ปีที่แล้ว

      @@SATSifaction Well, if someone already knows Python and don't want to learn VBA, and I totally get that, they should use Python. I'm just saying we should use the right tool for a given task. VBA is much faster if used right (being the native language), more accessible (built in IDE), bit more friendly for absolute beginners. Someone who develops Excel automations, it's worth learning both languages. If speed is important, and many times it is, VBA is mostly unbeatable.

    • @twasif
      @twasif 4 ปีที่แล้ว

      @@danielszalok8540 There are several additional functionalities you can add to this code such as job scheduling, sending emails, etc. Although this too can be done via VBA, the coding would be much difficult compared to python. I would say python is pretty easy to learn for anyone with no prior programming and IT experience. Utilizing the features of python and excel power query, a lot of tasks can be automated.

    • @twasif
      @twasif 4 ปีที่แล้ว

      @@danielszalok8540 VBA would soon be outdated the way things are going ahead..

    • @danielszalok8540
      @danielszalok8540 4 ปีที่แล้ว

      @@twasif outdated doesn't mean inefficient, or difficult to use, or slow

  • @joey5069
    @joey5069 4 ปีที่แล้ว

    thanks! when I run the code I get the error: Traceback (most recent call last):
    File "split.py", line 42, in
    print("Your data will split based on these values {} and create {} files or sheets based on next selection. If you are ready to proceed please type 'Y' and hit enter. Hit 'N' to exit".format(', '.join(cols), len(cols)))
    TypeError: sequence item 0: expected str instance, float found
    joeymeijers@MBP-van-Joey-2 split %
    how can I fix this?

    • @markanderson8066
      @markanderson8066 4 ปีที่แล้ว

      You might want to check the value of cols and len(cols), confirm the .format syntax.
      Haven't run the code yet.

    • @joey5069
      @joey5069 4 ปีที่แล้ว

      @@markanderson8066 I honestly can't find the problem. I am very new to programing.

  • @vtn1700
    @vtn1700 4 ปีที่แล้ว

    You can do all this in 10 sec with power query

  • @two_stones
    @two_stones 4 ปีที่แล้ว

    Here is the code on github: github.com/satssehgal/Excel_S...

  • @DY-pg9bn
    @DY-pg9bn 4 ปีที่แล้ว +1

    You haven't heard about GDPR, lol?
    Look forward to letters from you european clients))))