Skip to content

Commit 610e77c

Browse files
committed
extract files from zip in python
1 parent f974de2 commit 610e77c

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Extract contents of a specified path of ZIP file
2+
3+
A script to extract all the contents of a specified path of ZIP file.
4+
5+
## How to use this script?
6+
Just type the following in your command prompt:
7+
8+
python script.py
9+
10+
## Screenshot
11+
After running the script we will find the extracted file in the current directory.
12+
13+
![demo](https://user-images.githubusercontent.com/56690856/99091832-6add4280-25f6-11eb-999d-86d8b5794d57.png)
787 Bytes
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import pyshorteners library
2+
import pyshorteners
3+
4+
# input URL
5+
url = input("Enter the URL:")
6+
7+
# class object
8+
shortener = pyshorteners.Shortener()
9+
10+
# shortened URl
11+
urlShort = shortener.tinyurl.short(url)
12+
13+
# print shortened URL
14+
print("The shortened URL is:" + urlShort)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from zipfile import ZipFile
2+
3+
def main():
4+
# Enter the name of zip file
5+
zipFile = input("Enter zip file:")
6+
# Enter the path of the file to be extracted
7+
extractFile = input("Enter path of the file:")
8+
print("Extracted file in ZIP to current directory")
9+
# create a ZipFile object in READ mode and name it as zipObj
10+
with ZipFile(zipFile, 'r') as zipObj:
11+
# extract() method is used to extract any file by specifying its path in the zip file
12+
zipObj.extract(extractFile);
13+
14+
if __name__ == '__main__':
15+
main()

0 commit comments

Comments
 (0)