I've been getting lists in emails with line breaks for each item what I want to do is just copy and paste then save as csv and have a script create a python list out of the data. Since it's columns from the paste to the file I'm getting improper formatting, if I change I do a replace on the line breaks for commas it look a bit better but still since it's converted from a column it's not correct and with mylist.values.tolist() it still doesn't work. Here's what I have and what's happening. I can do this with the builtin csv library but was wondering how to do it in p
Email format that I'm pasting:
Fox Chicken Cat Dog
When I put into csv and put the commas:
Fox, Chicken, Cat, Dog
What I get back for output:
mylist.values.tolist()
[['Fox, nan'], ['Chicken, nan'], ['Cat, nan'], ['Dog, nan']]
I just want:
['Fox','Chicken', 'Cat', 'Dog']
Further, if I try to assign my_list = mylist.values.tolist() I get an exception the unsupported operands 'str' and 'type'.
Any help would be appreciated since I like pandas more than builtin, if it's not possible elegantly I'll have to go back.
[['Fox', nan], ['Chicken', nan], ['Cat', nan], ['Dog', nan]]?mylist? the exception in the assignment is strange, how could I duplicate it? please, put a small minimal but complete example of the exception.