Marko Marko 2 2 silver badges 12 12 bronze badges. So what's your problem? IanAuld: He is trying to read sentences rather than just the lines of the file Its not appending to a new list separated by each sentence — Marko.
Use a context manager to handle the file! Add a comment. Active Oldest Votes. Tommy Tommy 5 5 silver badges 8 8 bronze badges. He sighed, "Sure. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Note: the column name of the corresponding dataframe will be in the form of integers and i choose 0 because i was extracting only the first column. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to read a text file into a list or an array with Python Ask Question.
Asked 8 years, 9 months ago. Active 1 month ago. Viewed 1. The text file is formatted as follows: 0,0,,0,53,1,0,, Just as a note. It looks like this question should be rephrased as how to read a csv file into a list in Python. But I defer to the OP's original intentions over 4 years ago which I don't know. Related, likely duplicate of: stackoverflow. Does this answer your question? How to convert comma-delimited string to list in Python? In fact, looking at the top answer, this is a duplicate of stackoverflow.
Add a comment. Active Oldest Votes. Achrome Achrome 7, 14 14 gold badges 32 32 silver badges 45 45 bronze badges. I think that this answer could be bettered If you consider a multiline.
I'd like to add that, the above problem notwistanding, this procedure collapses data from individual rows in a single mega-list, usually not what I want when processing a record-oriented data file.
Show 4 more comments. TigerhawkT3 TigerhawkT3 This is a very pythonic way! I suggest using this one. Note that this use of next is for python 3. The Overflow Blog. Podcast what if you could invest in your favorite developer?
Who owns this outage? Building intelligent escalation chains for modern SRE. Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. Related Hot Network Questions. Stack Overflow works best with JavaScript enabled.
0コメント