Code:
(Note: It will work only if you open your file with variable e)
li=[];
for i in e:
i=i.replace("\n","").split(",");
li.append(i);
e.close()
Note the values are float , but in above list li , those are stored as string , you can further type cast to float using this below code:
(Be careful in converting string to float , the first row can not be converted into float as those are column names , for rest of the rows you can perform conversion)
li=[];
temp=0;
for i in e:
if(temp!=0):
i=i.replace("\n","").split(",");
gi=[];
for j in i:
gi.append(float(j));
li.append(gi);
else:
i=i.replace("\n","").split(",");
li.append(i);
temp+=1;
e.close()
Python for beginners:
https://www.youtube.com/watch?v=egq7Z...
Telegram: https://t.me/clcoding_python https://www.facebook.com/pirawenpython/ https://www.facebook.com/groups/pirawenpython/
Telegram: https://t.me/clcoding_python https://www.facebook.com/pirawenpython/ https://www.facebook.com/groups/pirawenpython/
0 Comments:
Post a Comment