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
JavaScript
x
13
13
1
import os
2
import csv
3
4
uuid = []
5
with open('C:/Users/Public/file.csv', 'r') as file:
6
reader = csv.reader(file)
7
for row in reader:
8
uuid.append(row)
9
10
for i in uuid:
11
filepath = os.path.join("org/datasets/", i , "/data")
12
print(filepath)
13
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 |
Advertisement
Answer
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)
JavaScript
1
4
1
for i in uuid:
2
filepath = os.path.join("org/datasets/", i[0] , "/data")
3
print(filepath)
4