Quick actions

cmd+k|ctrl+k

Navigation

Languages

Move CSV Files

Snippet info

Language

Python

Visibility

public

Author

abdlkdrgndz

Created

2021-03-02T18:48:53.453561Z

Updated

2021-03-02T19:12:29.443618Z

#author : abdlkdrgndz

import os, shutil, pandas

def readAndMoveCSVFile(filename):
    files, arr = pandas.read_csv(filename), []
    for i in pandas.DataFrame(files).values:
        arr.append(i[0].split(";")[0])
        path, moveto, extension = "current/", "new_path/", ".JPG"
        for f in arr:
            if(os.path.exists(path + f + extension)):
                src = path + f + extension
                dst = moveto + f + extension
                shutil.move(src, dst)
                print("{} file is moved.".format(f + extension))
            else:
                print("{} file not found.".format(f + extension))

# Tetikleyelim
if __name__ == '__main__':
    readAndMoveCSVFile('melos.csv')
INFO