Is it a good idea to have usage of both csv and text files in a python program?

Viewed 60

The program i am working on deals with reading and writing multiple text files. But where there was better to use csv files, i replaced the text files with csv files. Now my program deals with some csv files and some text files. My question is, it is alright to have both types of files in your program OR should I stick to only one type. I mean, all the files should be of csv type only?

Actually, i opt for this approach because for a single word per line, I was getting undesired result. The code attached below give a list of lists i.e [['1'],['2'],['3'],['4'],['5']] but I want a simple list of strings i.e ['1', '2', '3', '4', '5'].

import csv

def writeFile():
    with open('memes.csv', 'w', newline='') as myfile:
        dataWriter = csv.writer(myfile)
        for i in range(5):
            dataWriter.writerow([i])

writeFile()

with open('memes.csv') as myfile:
    datareader = list(csv.reader(myfile))

print(datareader)
0 Answers
Related