Categories
Mastering Development

Using csv how can u split an row to create independent data in variables? (My attempt bellow)Can u help improve it, thanks in advance.Python

def Start():
    with open('Songs.csv') as Data #Call file
    Read = csv.reader(Data,delimiter=':', quotechar='|')#return tuple of songs and artists
    for row in Read :
        X = random.choice(row)
        Store = (','.join(X))
        A = re.compile(‘,’)
        for s in finditer(Store):
            POS = s.start()#positional arg for slicing
            global Song
            Song = X[POS:]
            global Artist
            Artist = X[:POS]
            print(Song)

Leave a Reply

Your email address will not be published. Required fields are marked *