I have a CSV containing 28 UUIDs
I would like to create a python loop which runs each uuid individually and places it into a filepath
e.g. Org/datasets/uuid/data
I have tried the below but failing
import os
import csv
uuid = []
with open('C:/Users/Public/file.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
uuid.append(row)
for i in uuid:
filepath = os.path.join("org/datasets/", i , "/data")
print(filepath)
error is TypeError: join() argument must be str, bytes, or os.PathLike object, not 'list'
The CSV is very simplistic and looks as follows:
uuid | blank |
---|---|
uuid1 | blank |
uuid2 | blank |
CodePudding user response:
In your for loop ever value of i
corresponds to a row in your csv file. As such, it comes out as a list, something you cannot concat against a str. Instead, you should be taking the first element of your list(the actual uuid)
for i in uuid:
filepath = os.path.join("org/datasets/", i[0] , "/data")
print(filepath)