If I understand you right, you have a csv file which looks like this:
title1,date1,text1
title2,date2,text2
title3,date3,text3
If you want to split the rows, simply use the .split()
-function.
In this case, it'd look similar to this:
columns = row.split(',')
The .split()
-function returns an array full of strings, therefore, if you want to access column 1, you have to say columns[0]
.
If it's the first row, columns[0]
would give you title1
with my data above.
Another example:
filename = 'data.txt'
lines = [line.strip() for line in open(filename)]
for row in lines:
columns = row.split(',')
print ' '.join(columns)
Using this code, gives you the following output:
title1 date1 text1
title2 date2 text2
title3 date3 text3
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…