Python Download Files From SharePoint Using Office365 Rest Package Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what up guys what uh what up i am lou all right guys so today we're gonna be talking about python sharepoint api right so we're gonna be working with a new package so i have made other videos in the past um you may find videos that i have made this is maybe like two years ago which pretty much was python connecting to a sharepoint site to download documents right like download files or upload files so the the package that i use in those videos was shareplum so i'm actually i'm gonna this video is gonna be more so focused on another package the other package is called office 365 api now i've been playing around with it doing some testing on it and i actually like it a lot it has a lot it's very feature rich and so i kind of decide i'm going to do a multi-part video it's going to be probably a good five six videos maybe even more but at least five six videos and it's gonna be all related to this office 365 api package and one video which the video we're making today is going to be downloaded files from sharepoint again i have a video already related to that but i'm using a different package okay so we're going to kind of walk through the process of getting that configured getting everything set up um and then on top of that there are some benefits with this package and i'll kind of explain the video uh why is probably more i would say uh better than share plump um and i'm gonna give a good use case you know for that throughout the video but nevertheless guys they're gonna be many more videos related to this so if you're interested on using python to interact with sharepoint maybe it's it's to check the version of files maybe it's to download files to upload files um whatever right i'm going to be making a list sharepoint list um things of that nature i'm gonna be making a few videos but i'm gonna call it gonna be a multi-part series so i'm gonna make this is gonna be called part one and it's gonna be downloading sharepoint files part two we'll probably be uploading sharepoint files part three would be um you know interacting with the sharepoint list or download sharepoint list or whatever the list goes on and on there'll be you know a lot of different features when it related to sharepoint in this case it will be related to sharepoint specifically um and all of this will be on my uh github account so go ahead and look at the check the link out my github account and um you could check get the code from there hey guys before we get started if you could give me a like give me a follow guys man i really really appreciate it man give me a like give me a follow and now let's get started all right guys so this is a fresh project and we're going to be adding on to it as well um it will make things a lot easier as well so when people right now the code source code for some of the other video that have made they're kind of scattered on different repos this will be on one repo plus you know things have kind of changed from the way i coded um the way i from the code that i wrote two three years ago because i think you know the video probably even go that far back almost three years back you know it's slightly different so it's gonna kind of start fresh so i'm in my folder already again you can tell it's brand new it's empty nothing in there like always guys like always like always like always create a virtual environment always man don't ever ever just start installing third-party packages in your current uh environment so let's go ahead and do that real quick so it'll be python 3 hyphen m v nmv and i'm going to call this env oops my bad it's python not python3 just python i wasn't working on my mac earlier and on my mac um i had to use python 3 which is why i think i'm just again that's kind of the little nuances when you're bouncing from one operating system you know one month one machine to another machine uh because yeah either way but all right cool so now that i have that let's go ahead and activate it uh source cnv scripts again remember guys those who are new if you're on macro linux it will be ben in my case i'm doing this on windows so it'll be scripts activate so now that i have that activated there's only one package that we're going to need um for this project so let's go ahead and get that package um in this case let's go to the website i just want to show y'all real quick um so let me go to the website so it will be python office 365 a rest python client it's what it's called um [Music] there it goes so this is it right here and [Music] uh so you know what this is actually not the latest it says 2.20 that's not the latest i believe the latest is 2.3 10 13 maybe something like that um he may have it over here what does he have there goes this is the latest version which was actually updated 26 days ago so it's being it is being maintained um the package which is always a good thing right it's always scary when you know you're dealing with a package that have not been maintained in years those packages i would most likely stay away unless it's dealing with some kind of issue that's very archaic and there's no need or there haven't been a need to update throughout the years but besides that i will kind of stay away from it but either way guys at least you know that kind of gives some insight to the um to the package let's go ahead and get this installed it will be pip install office 365 rest python client it's long as name but not sure what what he was thinking about how we generated that in that name all right cool so now that we have that package installed now let's get started so we have our virtual environment um we're going to create two files right or three files three files really so let's just go ahead and get our files configured one of the files is going to be i'm going to call it download um uh downloads uh download.py right so this download.py you're going to show like on um provide the code on how to download it pretty much the other file we're going to create we're going to call this office 365. um [Music] underscore office 365 api so let's call it that office 365 api cool then our third file is going to be called all env so we're going to be setting some variables that we're going to want to use throughout the application uh throughout the process so that's where this comes in if you're not familiar with um environment and variables then you're going to get familiar with in this video because we're going to be using it we're going to be talking about it all right so let's go ahead and let's put this code together so this file is going to have um we're going to create a class and then we're going to create functions to do specific tasks to authenticate to you know download file upload file all of that stuff but again we'll right now we're only gonna pretty much add the pieces that we need which is gonna be to download so let's go ahead and bring in certain packages so one thing that we're going to bring in is going to be for in order to handle our um environment uh environment variables so go ahead and import uh did i spelled it wrong oh nope okay um all right so the next thing that we're going to bring in is going to be from office 365 dot sharepoint dot client contacts import client context so this is going to be um what we're going to be use the class to authenticate so that's why we're bringing that in so the next one that we're going to bring in will be office 365 uh runtime aus then user credentials um let me try to think do we i don't know i don't think oh you know what we do need this um yes we do and i'll show you know we'll kind of walk through that but there are there user credentials import and what does it call your credentials so this is needed part of the authentication to create our um uh to authenticate with credentials because you could authenticate with token or credentials in this case would be credentials so next will be office 365 sharepoint uh files file.import file so again we're dealing with files here because we were dealing with sharepoint files we're bringing in the file class uh for that now again i'll explain on how that's that would work and all that in in a minute and we kind of go through the process all right so now that we have that i'm going to create an object called env and then this is going to bring in uh we're going to end up bringing in the env class so see now we're utilizing it over here we're bringing in the enemy class why do i what i have to squiggly lines what am i importing me cannot be resolved yeah i'm not sure why i'm getting that but um [Music] let's see all right cool so the next thing that we're going to do is let's go ahead and set our in inside this class we have a read env method now what this is doing by default is looking inside the same root directory where you're working at which in this case would be this file let's look inside this folder and it's looking for a dot env file so you can tell i have this dot env file right here and it's looking for because it wants to read all the variables and bring them in and as it brings them in it gets utilized throughout the application so that's pretty much what that's doing so what we where we're going to need is we're going to end up creating we're going to need um to from this file this dot interview there's going to be um five variables that we need to set so let's go ahead and set them now right let me kind of show you how that looks so one of them is going to be called sharepoint user uh you know what it's called is sharepoint um email right that's really what it is so be equals double quotes then again it'll be the email whatever email you relate you're you're dealing with sharepoint password um what else uh sharepoint urls site sharepoint oops site name and then it will be sharepoint doc library all right so again this this sharepoint email is going to be your office 365 email account right so if you're you know whatever your email account is that you log into your sharepoint site that's pretty much what that is and of course then your password is say same thing right your password for your office 365 account now the sharepoint url site and site name let's kind of walk through that i want to make sure that you understand what this is and where it's you know on like the format of it right so that's the piece that i really wanna make sure that you're you're you understand um so let me go ahead and open up office my sharepoint all right so this is one of my sites that i have it's called levelment so i'm going to click on it so as you could tell see up here on top where i have my sub domain then i have my domain which is sharepoint.com and then the it cites the levelment this right here is considered over here my url site right so it's not just the the um the url for sharepoint it's the actual site url right because again this name changes if you're dealing with different sites so you want to specify the right site that we're going to be downloading files from that's what that is this piece here where where it says um site name this is going to be how you know what it says site name this is our site name right here so go ahead and copy your site name then put a forward slash at the end um what else so well you know what let's not put forward slash we could remove it we're gonna exclude forward slash that's fine so we don't need it that's our name and then we have our what's called dog library so this piece here it could be a little bit tricky but hopefully it makes sense so when you go to sharepoint you have your documents folder on the left side right so your documents folder this is where you could have folders and subfolders and so on and so on well we don't want to specify the actual folder yeah we want this folder here to be dynamic see how i have two folders 2020 and then 2022 um we we're building our script whereas dynamic where these are going to be arguments that we're going to pass in to know which folder in sharepoint we want to download files to we don't want to hardcode that in but nevertheless going back to what what do we need here what is this this is actually we will click on the documents we're gonna we're pretty much trying to configure the root uh past you want to call it right in sharepoint where all of your files folders will be located under so in this case it is it's not data right it's that's not what it is but if we go to the root even a higher level than that it is called shared documents see how we have shared percent 20 which it's it's a percent 20 rep pretty much represents a space for the url then of course is documents that's what that's our what's going to be our doc library so that's what ultimately we're going to type in here so it'll be shared space because that's what it is documents forward slash um again i guess we don't need to prefer um no on this one we do need to put forward slash um all right but again this is where we're configuring all of our variables right so whenever you deploy it to your server for example this is not hard coded into your code these could always get changed as needed maybe you're working on a different uh site so you can just come into the configuration this file and then change it to the right site things of that nature right so it kind of gives a little bit more control control i'll put in my email password in a few but i do want to kind of show you this real quick all right so the next thing we need to do is now we're going to create uh we're going to assign we're going to pretty much read these variables and assign them um to a python variable so let's go ahead and do that the first one would be username um which again is going it's actually email so in this case it is let me kind of put this to the side it's going to be sharepoint email the next one would be password and this would be sharepoint password all right the next one is going to be sharepoint site um and this would be sharepoint url site now hopefully you see the pattern right all of these keys are pretty much the key value on what's in the the uh env file right this is our key and this is our value in double quotes key value so we need to specify the key in order to get back the value we're assigning the value to these objects right here that's pretty much what we're doing here right again some of the stuff that i'm saying you know those of you who are well experienced you know in programming in general are probably like dude we don't we know that already but i'm saying it more so for the people that are that are new i know i do have some people that watch my video that are just starting to learn how to program and so that's kind of the reason why some of the stuff that i may go over may seem very very basic or very entry level but trying to do it more so to help out to bring some understanding for the people that are brand new sharepoint uh doc so in this case would be sharepoint doc library cool so now that we have that let me go ahead and close this out just so we have more space to see better um and now what we're going to do next is we're going to end up creating a class and we're going to call our class sharepoint and inside this class we're going to have a few methods so we're going to end up creating let's the first one will be our authentication to authenticate so in this case we are uh let's call it underscore us this will be self um this would be co in um for connection and then that's we're going to end up bringing in our client contacts and the first classes based url so this is where we're going to end up providing our site sharepoint site so it'll be sharepoint site comma so now see where it says us context equals none so we are going to actually leave it as none in this example uh in this case but there is inside this class there is a a function that's called with credentials right we have access token a client start insert you know um with user credentials and so on but we're using the with credentials which is username and password um eventually i'll be making another video where we use tokens but in this case we're using credentials so now that i do that credentials we're going to end up see where it says right here credentials user credentials so that's what we're going to be using in here uh let me go ahead and enter it will be user credentials and then that this class takes in um two arguments the first one is the username and the second and one is password so we're passing those to you and ultimately once we pass all of that in we'll give back our connection to the site all right and we need to return that so this will be oops this will be a return c and then c-o-n-n for connection all right so our next function that we're gonna have is going to be called uh get files lists right so let's do self and it will take one argument folder name so what this is doing is um since we're gonna we're doing like a wild card like hey we want all the files in the folder well in order to know what's in there to begin with because it's not like a normal directory where like in python you could access your a list of files in a directory by using like the os um files you know uh package that's built inside python you can't do that in this case for sharepoint because it's it's it's you know it's a different you know location doesn't work the same way so what we're going to have to do is we're going to pass in a folder name and then we're going to access the metadata of that folder to see what is all of the file that exists in that folder and then once we get that list then it will be able to iterate over one by one and download each file that's pretty much what we're doing here but again to kind of separate the code and kind of have it do different things we have in this case we have a function that's gonna go get that data for us the metadata for what's filed belong in that folder or in that folder better yet so in this case we're going to do uh do a connect um self underscore als again we're calling this function over here since all of this already pre is pre-configured will give us back our connection the next thing we need to do would be target uh folder url so we need to specify which folder in sharepoint where we're seeking pretty much right um so in our case we're gonna end up we gotta build that url pass so but we're not going to specify the full url path like we're not doing the https domain subdomain.sharepoint.com then whatever so on and so on we're not specifying everything we need to specify everything from the shared document on forward right so again kind of going back we if we look at the um sharepoint site it would be like shared documents then if i click on data it will be data let's say 2022 will be 2022 so that would be kind of the url um the that that target pass that we're going to be specifying since we already have a lot of that said we're gonna pass in this case we're gonna go ahead and um uh bring this in sharepoint doc right so we have that in sharepoint doc uh let me check real quick if i look at sharepoint doc i do got a forward slash in here um okay oh my bad the um is this right you know what i don't need this let me remove this i'm going to remove that so it'll be sharepoint dock forward slash again i could have done it in my environment variables but i'd rather [Music] rather see it so the next thing here would be my folder name which again it's part of my argument so i'm passing this in it's going to end up building that pass my target so now that i have that um i'm going to now specify i'm going to call this uh root folder equals my connection web again web is part of this content client contents class it would be called get get folder by there it will be this by url pretty much and then of course i'm going to specify my target folder url right so that this ultimately is going to kind of think of it as specify the the full url and then concatenate the target url and that's why i call it root folder just kind of puts all of that together and all right so once we do that root folder in this case would be what expand and it would be files and folders all right then it will be get dot uh execute execute query all right now by doing that we will we would end up accessing the data that ultimately it's it's an object inside that class for all the file that exists so for my return it will be returned folder files and that will give me back all the files that exist in that folder in sharepoint so that's kind of what this is doing all right um so the next uh function that we're gonna create is going to be called uh we're gonna call this um download file it will be self we're going to specify the file name and then the folder name all right and then this same same thing with this one we're going to do a connect um [Music] you assign our connection next we're going to specify our file url right so in this case it would be uh forward slash sites and then it's going to be sharepoint site uh name right we want the sharepoint site name and then the next thing going to be our sharepoint doc variable that we have and then to finish it off it's going to be oops folder name and then it will be file oops damn it and file name uh let's see so now that once we have that we're gonna we pretty much get back a file object so that's why i call it file this is where we're using our file class from office 365. so in this case will be file open which there's a message called open binary and this is where we're gonna our first um under context is gonna be our connection that's what we're passing in our second argument is going to be our file url that's you know which is this guy here we got to specify that to know which file we want to download pretty much what we're doing here and then we're going to return oh damn it return that file object back now that file object contains many you know other metadata that we're not going to use but eventually we'll see in the process we'll and the other piece will kind of um only keep the context of it so we'll do you know i'll show you that in a few all right so our next um method that we're going to create let me call download files right so again this is file this is files so it would be self folder name and then what i'm going to do here it's going to be self underscore um uh let me see this would be underscore file file list and this will end up calling the cell the um my bad uh yeah it would be self underscore get file list method that i have over here right now i do have to pass in a folder name which is what i'm what i'm doing here and ultimately this is going to give me back a list so even though it's called download files it's really what it's doing is giving me back a list um and then i'm going to return my bad return underscore file list so probably just let me just do it this way i don't know why i put it under score so ultimately we'll return back that list um you know what just to maybe make it even reduce another line of code let me just do it like that and that will get returned that back so we got again we have we have our class with four uh methods one is to authenticate get file list remember again get file list is to be able to since it's not a normal directory the way you would be dealing with files on a local machine or a remote machine uh we need to determine what files even are on that sharepoint folder and based on this will give us that data then we would now when we have that data we'll be able to do an iteration and start downloading them one by one which is where this kind of gets built it built and ultimately downloads of each file one by one that's pretty much what's happening here so now that we have this set now let's go to our download.py file so what we're going to do here we're going to need to bring in that office 365 api file and we're going to import the sharepoint class all right so that's number one um number two is going to be regular expressions i'll explain to you why we're gonna bring that in next we're gonna bring in um system os um i think that's it system and os and then we do need to bring in uh from pass lib import peer pass because we're going to be saving right as we download we're going to save them somewhere so this is going to kind of build the the root pass and the file name together to be able to save it so the next piece um we're going to have some arguments let me just go ahead and put these in here so again if you were to see my other video this this piece will be very similar to what we did before slightly little tweaks but very similar so where the way we're building it is when we run when we execute this file we need to pass in some arguments in this case we have argument one it's file name argument two so keep in mind in python you know the starting index is zero you could tell i'm pulling i'm specifying one those of you who know who are not aware the file name is index zero by default so that's why we don't ever use zero we gotta use the next one which in this case would be one two three and four and again um we're what we're gonna do the way we're building it i'm building it where you know we got to specify the the sharepoint folder starting point and subfolders that will be an argument you got to specify the destination where do you want to save these files to as you download it could be somewhere local it could be a network drive doesn't matter if you need to specify the full group pass on where you want to save it to then file name this is more if you just want to download one file you don't want to download all the files in the folder but you just want to download one file that's the case you got to specify a file name then of course file name pattern if you let's say you have a folder that has two different types of files that you have sales files and then you have another one called called calls you know and it's those values the key values are in the file name well you can specify only one cells and it would only look for file name that start with the word sales or contain the word sales better yet and it will download those files right so inside this file and we're gonna create um four uh four functions so let's go ahead and create the first one that we're gonna create here it's going to be save file right so this is going to take in two arguments so it would be file name um yeah file name and then it would be file object all right uh the next thing what we're gonna do here is we're gonna we're gonna build our full root pass right where like ultimately this is where we're going to want to save it to so it'll be file uh directory pass equals pure pass and then you know in this case we're taking in the folder destination so what i want let me do this because i should have done this let me make these caps i just like having these in bigger case kind of you know distinguish the difference and that's where this will come in so this okay this one for example is folder name file name file name pattern all right cool so this will be folder destination like where we want to save it to um and then of course the um it would be in this case the file name which is this argument that we're passing in all right so this just building that string right next we're going to do with open in this case it would be the file directory pass and then we're going to do a wb which is a write binary even though we we're dealing with text files as well but wb would um think of it as we'll be able to save text files binary files whatever you know with this process and we would just write only be writing um you know text type files and since we again we could be dealing with different types of files it is easier to do it this way um then this would be right and this is where i will provide the file object right so this is where this comes in because this is the object that we actually want to write to you know this destination pass that we have uh so that's that that's that's the in order to save on whatever we want to save um the next thing will be it would be get file so we got we're gonna have a git file uh method so this would take and get a file name and then it will take in the folder um uh yep so we're taking the folder all right so next what we're going to do here is going to be file object because we need to get back an object first that's what we're doing we're going to get back an object and then i'm going to end up calling my sharepoint class then i'm going to end up calling my download um file uh function which is again it's this guy over here and ultimately all i'm passing in i'm gonna be passing two arguments file name and folder because again i need to tell it which file i want to download and the folder to go and fetch it from and then of course uh this is where i'm gonna end up calling my save um [Music] my save function that i created up here right so i need to pass in a file name then of course i'm going to pass in my file object as my two arguments and that takes care of that this takes care of you know the get files right we're getting it then we're saving it and i'm calling to save up here the next one is going to be called get files right with the s so they get files it's only going to take back the folder only right because we want all the files we don't want just one we want all so we're going to be just the the argument folder so this would be files list because we want to get back a list of what we want to download so now i'm calling sharepoint class and this will be download files then of course i'm going to specify my folder name um so honestly the more i think about it this probably should not be called download files yeah i don't even need the download this is not what i need here um and i say that more so from a sense of this is giving me the same thing yeah i don't know why i got this here man this this is not needed let me remove that i don't need it i'm actually going to call this mess it over here this is what i need which is going to be the get files list i want to list the files pretty much and this is a folder so it's going to give me back a file files list now i'm going to do an iteration so be for file in files list and then this is where again i would end up calling my git file class i'm going to end up specifying the file name so this is what as we iterate over the list of all the files in order to be able to extract the actual file name it would be files dot name all right that's how you would do it and then of course uh then it would be a folder because a folder again specifying which folder to download from and that's did not need this over here to know the file name and the folder where to go download the files to so that's kind of where this is taken care of so the last function that we're going to create is going to be called get files by pattern all right so this is going to take a pattern um it's going to take a pattern argument and then a folder again the pattern means we're looking for a specific whatever whatever keyword we're searching for it's going to try to find that in all the in the file names in sharepoint and only the file that have a match it's going to retrieve those you know download those files pretty much so this would be same thing will be files list sharepoint underscore get filed list folder because i got to specify the folder once i get that same concept right i'm going to do an iteration for file then files list and this is where i'm going to do my pattern matching right where regular expression comes in so it'll be if re um search that's what it is i'm doing search then i'm going to pass in my pattern oops pattern uh what the hell did i spell it wrong damn it i'm not spelled it right over here all right so be pattern then of course file dot name so again the pattern being i'm looking for the keyword cells that's the pattern um let me just call it pattern name or pattern value or um keyword better yeah that's probably better let's call it a keyword and then ultimately i'm looking for that keyword inside the file name and if there's a match it will return true that's what the regular expression.search does if it doesn't match it returns false so in python when you do an if some bad like let's say you do if true it will execute the code underneath if it's if false it does not execute the code and that's why what i have it will again i'm talking about for the people that are new but it's trying to kind of provide some additional knowledge in that area um so in this case if there is a keyword there is a hit there's a match then i'm gonna do git file and get files gonna want the file name then it's also going to want the folder and that's it that's how it is able to do that so the final piece is going to be when we run the file we want this to run so by default that the name of it's call main um because this is the faux file that we're running and because it's main and this is true it's going to execute the code right below it so have you ever seen this but you're not sure like why is that there and so on that's why anytime you run the file that file has the name of underscore underscore main and because it has that name we build logic where this match this matches the underscore underscore main it's gonna run the code under lease under automatically and this is where we're gonna now build some logic if um file name is not right is not none which means they provided the file name of the argument right kind of going back where if you're the user you provide a file name you do provide a file name then is what it's going to do is going to say okay go ahead and just automatically execute the get file and in this case it would be file name as one argument and then it would be a folder name all right so else if the next thing is going to be file name pattern right if dad is not none again which means that the you provided um a pattern there's a pattern there associated some kind of value that's an actual pattern then without what we're doing here we're going to say okay go ahead and get filed by pattern that's what we want to run and then we're going to pass in the file name pattern variable and then the folder name all right and then else else is again whatever remains it's going to do be the get files right so in this case it would be folder name only so that's it so now if we run it you know it'll what i what i need to do here let's create a new folder and i'm going to call this um storage because that's where i want to see files i want i expect files to populate and be and show up there this folder if everything's successful um so now that we have got this file in order this looks to be an order um okay so the only thing i need to do let me provide my email and password and then we could test it out and run it and again i'm connecting to this sharepoint site here and i'm gonna be trying to download files from this 2022 folder that's my goal here right so ultimately these files should get downloaded you could tell there are different type of files you have csv and then one excel so let's see if this works let me go ahead and put in my credentials and we'll do a test guys and see if this worked out let's see if it work i know it's going to work but let's see if it works the first try right that's always a thing can we get it to work the first try most of the time not but we'll see all right cool so now what i'm going to do is again remember this folder is empty here right there's no files in here um [Music] i'm connected to that project so let's go ahead and run it i'm gonna do python and i'm going to run download dot py so again we're going back to we have four arguments we need to pass in right four arguments um sharepoint file name this one need to be used what i should have noted here as well is um if all files will be down loaded then set this value as none right so the reason why when us we want to set it as none is because it needs some kind of key value you need some kind of argument can't just be blank so same thing with this guy when all files are going to be downloaded when off uh when uh not all files when a no pattern match files are required to be downloaded then set this value to none as well so it will be none so now let's go to it right so what i'm going to do here is my folder name that i'm going to be looking for it's going to be again not documents do not put documents it's going to be data 2022. all right so just keep that in mind that's what it's going to be so i'm looking for [Music] data forward slash 2022 all right my next argument here is going to be where do i want to save this files to right so it's right here this is a this is it i want to [Music] copy pass let me just make sure yep this is it so this is the path that i wanted i'm going to put space again remember this is argument number one by default when you run a python file then this is which is index 0 then of course they have argument 2 which is index one then this will be my our my third argument which is index two put in double quotes space and then i'm not specifying a specific file because i want all the files i just don't want one file when all files and i'm not doing pattern matches either in this case so this would be none space none all right so now let's go ahead and run it see what happens oh [Music] so this is all why they're not finding it um all right guys so what we're gonna do next is so i figured out the issue i don't know how i missed this man so we need to install one more package there's two packages with packages we're installing for this project one of them being the office 365 then the next one is going to be the pip install django for the environment variables right so once we get that installed which is now installed um yeah we should be good now so then let's go ahead and run it so i'm gonna run uh again python download.py the the folder in sharepoint where we're going to download files from then of course we want to save it to none none because we're not doing single file download or any pattern match download we want to download all the files let's go ahead and run it all right it's running that's good oh what happened oh you know what damn i know what happened yep so now let me go back to my download uh where's my download at um [Music] so this is going to be as i download files i get back an object so you know what this may be something i could fix here under downloads so it would be file um let's see what i could do here would be dot um context so again i didn't want the context data only not the full response so that's what i should have done here so now let's run it again cross fingers make sure it works all right hasn't errored out let's see what do we have in store oh boom there he goes we got our files and it's done cool so you could tell we were able to connect and we downloaded all the files to the the folder that we specified right and um and it worked like a charm it worked the way i expected it to work so let's go ahead and delete these move to recycle bin now that we have that empty what i'm now let's try it one more time but let's do pattern match right same thing same same folder like same location in sharepoint the data 2022 which is um damn where is it at that's not it oh i have it over here my bad so again data 2010 not documents that you know you're not going to specify documents only you know uh the starting point which is data 2022 and then single file still none but my wild card i do want to specify i want to specify january right and the reason why january because if i go back to it we have one file or better yet customer i do want i just want the file with the word customer in it that's actually better customer so that's what i'm looking for and hit enter and let's see what we get boom one file two three boom that's exactly what i wanted three files and we did no errors so again the pattern match worked like a charm would specify a specific pattern name that we're looking for and it worked so again this is a update from a previous video that i have made but i'm using a different package i'm using office 365 rest api python or cloud whatever it's it's a long as a long name but nevertheless i'm using that package um i like it i've been playing around with it as well and i do like this um this package i think it's more feature-rich than sure plump so this is part one i'm going to be making more videos and what i'm going to be doing is adding on to this project right instead of having multiple repos of different like examples to download or upload or whatever i'm going to have this one repo and i'm going to be adding on to it so that's why i have a download for folder the next video i will create an upload for um upload file you know up or you know in this case called download i probably should have called it download um i am going to change it i need to change it i'm going to change the file name to download files and then i'll create another one that will be called upload files and then so on and so on right you know just kind of add on to it and you'll see this class sharepoint class i would add on i'm going to add more functions to it you know instead of just having a download function i'm going to add a upload function and you know so on and so on so again guys i'm going to be adding on to it hopefully this helps out hopefully this works helps out again guys give me a like give me a follow i appreciate it there'll be more videos to come peace
Info
Channel: I am Lu
Views: 41,667
Rating: undefined out of 5
Keywords: SharePoint, Python, API
Id: dkxVTX5Hs_Q
Channel Id: undefined
Length: 58min 57sec (3537 seconds)
Published: Mon Jul 18 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.