How to copy certain files from one folder to another using Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:40:29
The shutil module provides functions for copying files, as well as entire folders. For copying multiple files at once, you'll have to have a list of all files you want to copy and loop over them to copy them.Calling shutil.copy(source, destination) will copy the file at the path source to ... Read More

How to copy files from one folder to another using Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:38:01
The shutil module provides functions for copying files, as well as entire folders. For copying multiple files at once, you'll have to have a list of all files you want to copy and loop over them to copy them.Calling shutil.copy(source, destination) will copy the file at the path source to ... Read More

How to compare two different files line by line in Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:34:49
The Python standard library has a module specifically for the purpose of finding diffs between strings/files. To get a diff using the difflib library, you can simply call the united_diff function on it. For example, Lets say you have 2 files, file1 and file2 with the following content:file1: Hello People ... Read More

How to find the real user home directory using Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:21:50
To get the homedir in python, you can use os.path.expanduser('~') from the os module. This also works if its a part of a longer path like ~/Documents/my_folder/. If there is no ~ in the path, the function will return the path unchanged. You can use it like:import os print(os.path.expanduser('~'))You can ... Read More

How to use Glob() function to find files recursively in Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:19:28
To use Glob() to find files recursively, you need Python 3.5+. The glob module supports the "**" directive(which is parsed only if you pass recursive flag) which tells python to look recursively in the directories. For example, import glob for filename in glob.iglob('src/**/*', recursive=True):     print(filename)You can check the ... Read More

How to touch all the files recursively using Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:16:26
To touch all the  files recursively, you need to walk the directory tree using os.walk and add touch all the files in it using os.utime(path_to_file). For example, import os # Recursively walk the tree for root, dirs, files in os.walk(path):     for file in files:         ... Read More

How to zip a folder recursively using Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:14:06
Use the zipfile module to create a zip archive of a directory. Walk the directory tree using os.walk and add all the files in it recursively. For example, import os import zipfile def zipdir(path, ziph):     # ziph is zipfile handle     for root, dirs, files in os.walk(path): ... Read More

Difference between SAP ERP and a DBMS system

Sravani S
Published on 27-Dec-2017 14:30:35
On a very basic level, a DBMS is a method for looking at something. For ex. SQL Server, MySQL, and others. It is basically a program that lets you communicate with databases.Database management system is a product which sorts out information in a database, gets information, controls and manipulates information. ... Read More

How to create a zip archive of a directory using Python?

Rajendra Dharmkar
Published on 27-Dec-2017 15:10:16
Use the zipfile module to create a zip archive of a directory. Walk the directory tree using os.walk and add all the files in it recursively. For example, import os import zipfile def zipdir(path, ziph):     # ziph is zipfile handle     for root, dirs, files in os.walk(path): ... Read More

Interfacing database to external parties in SAP system

Ramu Prasad
Published on 27-Dec-2017 14:32:40
Interacting directly with SAP databases is not considered a good programming practice. As SAP database is nothing but a normal database, it can interact in any way like any ODBC technique - ADO.NET or other.Remote Function Calls can be used to make calls to databases. ERP Connect supports RFC and ... Read More
Advertisements