HomeSoftware EngineeringThe best way to Transfer Recordsdata From One Listing to One other...

The best way to Transfer Recordsdata From One Listing to One other Utilizing Python


If you’ll want to transfer information from one listing to a different listing, utilizing Python, then you are able to do one of many following:

Choice 1 – Utilizing shutil.transfer()

import shutil
import os
 
file_source = 'supply/listing'
file_destination = 'vacation spot/listing'
 
get_files = os.listdir(file_source)
 
for file in get_files:
    shutil.transfer(file_source + file, file_destination)

Choice 2 – Utilizing os.exchange()

import os
 
file_source = 'supply/listing'
file_destination = 'vacation spot/listing'
 
get_files = os.listdir(file_source)
 
for file in get_files:
    os.exchange(file_source + file, file_destination + file)

Choice 3 – Utilizing pathlib

from pathlib import Path
import shutil
import os

file_source ='supply/listing'
file_destination ='vacation spot/listing'

for file in Path(file_source).glob('some_file.txt'):
    shutil.transfer(os.path.be part of(file_source,file), file_destination)
RELATED ARTICLES

Most Popular

Recent Comments