You will have to split your string into a list of values using split()
So,
lines = text_file.read().split(',')
EDIT: I didn’t realise there would be so much traction to this. Here’s a more idiomatic approach.
import csv with open('filename.csv', 'r') as fd: reader = csv.reader(fd) for row in reader: # do something
Related Posts:
- TypeError: list indices must be integers or slices, not str
- Python List vs. Array – when to use?
- Python: Array v. List
- TypeError: list indices must be integers or slices, not str
- How can I create an array/list of dictionaries in python?
- numpy-equivalent of list.pop?
- TypeError: only integer arrays with one element can be converted to an index 3
- How to create a numpy array of lists?
- How is Python’s List Implemented?
- How can I reverse a list in Python?
- Difference between del, remove, and pop on lists
- How can I reverse a list in Python?
- How to declare an array in Python?
- What is the difference between Python’s list methods append and extend?
- Python – TypeError: ‘int’ object is not iterable
- Understanding slice notation
- Understanding slice notation
- IndexError: list index out of range and python
- Python – TypeError: ‘int’ object is not iterable
- ValueError: setting an array element with a sequence
- How to convert list to string [duplicate]
- How do I get the number of elements in a list?
- Finding the index of an item in a list
- TypeError: only size-1 arrays can be converted to Python scalars (matplotlib)
- Finding the index of an item in a list
- Accessing the index in ‘for’ loops?
- How to make a flat list out of a list of lists
- Print string to text file
- Removing duplicates in lists
- What does the list() function do in Python?
- List changes unexpectedly after assignment. Why is this and how can I prevent it?
- Why does this iterative list-growing code give IndexError: list assignment index out of range?
- TypeError: ‘float’ object is not subscriptable
- Numpy ValueError: setting an array element with a sequence. This message may appear without the existing of a sequence?
- numpy: Invalid value encountered in true_divide
- Is there a short contains function for lists?
- How do I create an empty array/matrix in NumPy?
- TypeError: ‘float’ object is not subscriptable
- ValueError: operands could not be broadcast together with shapes (5,) (30,)
- Transpose/Unzip Function (inverse of zip)?
- appending list but error ‘NoneType’ object has no attribute ‘append’
- numpy matrix vector multiplication
- Check if something is (not) in a list in Python
- Python: finding an element in a list [duplicate]
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- Finding the average of a list
- Writing a list to a file with Python
- How do I concatenate two lists in Python?
- if else in a list comprehension
- How can I randomly select an item from a list?
- Print a list in reverse order with range()?
- Convert pandas dataframe to NumPy array
- Get unique values from a list in python [duplicate]
- Fastest way to check if a value exists in a list
- How can I count the occurrences of a list item?
- TypeError: ‘list’ object cannot be interpreted as an integer
- Why is it string.join(list) instead of list.join(string)?
- Why is it string.join(list) instead of list.join(string)?
- How do I concatenate two lists in Python?
- if else in a list comprehension
- Finding median of list in Python
- Python set to list
- size of NumPy array
- How to find all occurrences of an element in a list
- Get list from pandas dataframe column or row?
- Finding and replacing elements in a list
- How to find all the indexes of a recurring item in a list?
- ValueError: all the input arrays must have same number of dimensions
- How to find list intersection?
- ValueError: max() arg is an empty sequence
- ValueError: setting an array element with a sequence
- Using Numpy Vectorize on Functions that Return Vectors
- Remove list from list in Python
- python – if not in list
- How do I concatenate two lists in Python?
- How can I compare two lists in python and return matches
- Is arr.__len__() the preferred way to get the length of an array in Python?
- Replace values in list using Python
- Append integer to beginning of list in Python
- List comprehension on a nested list?
- Is there a NumPy function to return the first index of something in an array?
- Numpy/Python Array Value error
- Union of two lists in Python
- Get unique values from a list in python
- ‘list’ object has no attribute ‘shape’
- initialize a numpy array
- Writing a list to a file with Python
- How do I check if a list is empty?
- load csv into 2D matrix with numpy for plotting
- How to access the ith column of a NumPy multidimensional array?
- Dump a NumPy array into a csv file
- Python: find position of element in array
- Python: Get the first character of the first string in a list?
- Understanding slice notation
- How do I find the duplicates in a list and create another list with them?
- Add list to set?
- What’s the idiomatic syntax for prepending to a short python list?
- How to remove an element from a list by index