user8220216
user8220216

Reputation:

directory name is invalid when saving csv to 3 seperate locations

I am trying to save to multiple locations but get the error message below.

    files = os.listdir(path)
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\ze\\ga.csv'

Any ideas on how to fix this?

 #!/usr/bin/python
    import sys, os, time, shutil
    print(time.ctime())
    path = 'C:\\Users\\ze\\ga.csv'
    files = os.listdir(path)
    files.sort()
    for f in files:
        src = path+f
        dst = 'C:\\Users\\ze\\ga.csv' +f
            dst2 = 'C:\\Users\\ze\\ga.csv' +f
            dst3 = 'C:\\Users\\ze\\ga.csv' +f
        shutil.move(src, dst)
    print(time.ctime())

Upvotes: 0

Views: 511

Answers (1)

Abhijit Pritam Dutta
Abhijit Pritam Dutta

Reputation: 5591

I have few python scripts where I also faced the same problem and I have modified the path like below which fixed my problem.

  path = "C:/Users/ze/ga.csv"

Upvotes: 1

Related Questions