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?
- Python – TypeError: ‘int’ object is not iterable
- IndexError: list index out of range and python
- Python – TypeError: ‘int’ object is not iterable
- ValueError: setting an array element with a sequence
- Finding the index of an item in a list
- Accessing the index in ‘for’ loops?
- What does the list() function do in Python?
- Numpy ValueError: setting an array element with a sequence. This message may appear without the existing of a sequence?
- Is there a short contains function for lists?
- ValueError: operands could not be broadcast together with shapes (5,) (30,)
- appending list but error ‘NoneType’ object has no attribute ‘append’
- Check if something is (not) in a list in Python
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- Writing a list to a file with Python
- How do I concatenate two lists in Python?
- How can I randomly select an item from a list?
- Convert pandas dataframe to NumPy array
- 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
- size of NumPy array
- Get list from pandas dataframe column or row?
- Finding and replacing elements in a list
- How to find list intersection?
- ValueError: max() arg is an empty sequence
- Using Numpy Vectorize on Functions that Return Vectors
- Remove list from list 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?
- Append integer to beginning of list in Python
- List comprehension on a nested list?
- Union of two lists in Python
- initialize a numpy array
- How do I check if a list is empty?
- 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
- What’s the idiomatic syntax for prepending to a short python list?
- numpy with python: convert 3d array to 2d
- Create 3D array using Python
- Python: slicing a multi-dimensional array
- Shuffle an array with python, randomize array item order with python
- Converting Dictionary to List?
- Python Sets vs Lists
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- How do I get an empty array of any size in python?
- How to deep copy a list?
- Python return list from function
- How to remove specific elements in a numpy array
- Add single element to array in numpy
- How to check if a string is a substring of items in a list of strings?
- How do I check if a list is empty?
- IndexError: list index out of range and python
- Pop index out of range
- Print list without brackets in a single row
- How to iterate through two lists in parallel?
- Make list of arrays in python
- How to remove \n from a list element?
- Map to List error: Series object not callable
- how to create a list of lists
- Python assigning multiple variables to same value? list behavior
- Python Array Rotation
- How do I check if there are duplicates in a flat list?
- How can I create a text input box with Pygame?
- Append a tuple to a list – what’s the difference between two ways?
- How to fix “TypeError: len() of unsized object”
- How can I remove all instances of an element from a list in Python?
- Create an empty list in Python with certain size
- How to concatenate items in a list to a single string?
- Numpy.dot TypeError: Cannot cast array data from dtype(‘float64’) to dtype(‘S32’) according to the rule ‘safe’
- What’s the difference between lists enclosed by square brackets and parentheses in Python?
- Appending to a list gives ‘int’ object has no attribute ‘append’
- Python data structure sort list alphabetically
- TypeError: unsupported format string passed to list.__format__
- How to plot an array in python?
- How to create a numpy array of all True or all False?
- Removing nan values from an array
- Root mean square of a function in python
- What are the differences between numpy arrays and matrices? Which one should I use?
- How do I merge lists in python? [duplicate]
- creating a reverse method for a python list from scratch
- Counting array elements in Python
- How to normalize a NumPy array to within a certain range?
- numpy array concatenation error: 0-d arrays can’t be concatenated
- Sorting arrays in NumPy by column
- In Python, is there an elegant way to print a list in a custom format without explicit looping?
- Hashing arrays in Python
- Determine if 2 lists have the same elements, regardless of order? [duplicate]
- Building a list inside a list in python
- Writing Python lists to columns in csv
- Can I put a tuple into an array in python?