It’ll be good to see the csv file itself, but this might work for you, give it a try, replace:
file_read = csv.reader(self.file)
with:
file_read = csv.reader(self.file, dialect=csv.excel_tab)
Or, open a file with universal newline mode
and pass it to csv.reader
, like:
reader = csv.reader(open(self.file, 'rU'), dialect=csv.excel_tab)
Or, use splitlines()
, like this:
def read_file(self): with open(self.file, 'r') as f: data = [row for row in csv.reader(f.read().splitlines())] return data
Related Posts:
- TypeError: list indices must be integers or slices, not str
- Writing a pandas DataFrame to CSV file
- Writing a pandas DataFrame to CSV file
- Where does pip install its packages?
- IndexError: too many indices for array
- Where does pip install its packages?
- django: TypeError: ‘tuple’ object is not callable
- ValueError : I/O operation on closed file
- Getting TypeError: __init__() missing 1 required positional argument: ‘on_delete’ when trying to add parent table after child table with entries
- Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
- No module named ‘psycopg2’
- Getting TypeError: __init__() missing 1 required positional argument: ‘on_delete’ when trying to add parent table after child table with entries
- Pandas: ValueError: cannot convert float NaN to integer
- csv.Error: iterator should return strings, not bytes
- No module named MySQLdb
- No module named MySQLdb
- How to check Django version
- Python – Reading and writing csv files with utf-8 encoding
- Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty
- is not JSON serializable
- Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty
- Python Error io.UnsupportedOperation: not readable
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock
- django:django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet
- load csv into 2D matrix with numpy for plotting
- No module named pkg_resources
- Django upgrading to 1.9 error “AppRegistryNotReady: Apps aren’t loaded yet.”
- Dump a NumPy array into a csv file
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- Can’t compare naive and aware datetime.now() <= challenge.datetime_end
- How to load a tsv file into a Pandas DataFrame?
- django import error – No module named core.management
- Forbidden (403) CSRF verification failed. Request aborted. Even using the {% csrf_token %}
- Create a .csv file with values from a Python list
- Convert XML to CSV file
- TypeError: list indices must be integers or slices, not str
- Django 2.1.3 Error: __init__() takes 1 positional argument but 2 were given
- Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock
- Setting Django up to use MySQL
- django:django.core.exceptions.AppRegistryNotReady: Apps aren’t loaded yet
- OSError – Errno 13 Permission denied
- Convert from CSV to array in Python
- Pylint “unresolved import” error in Visual Studio Code
- ValueError: cannot index with vector containing NA / NaN values
- (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
- Django – no such table exception
- django MultiValueDictKeyError error, how do I deal with it
- Creating a dictionary from a csv file?
- Python import csv to list
- Django – no such table exception
- Is there a list of Pytz Timezones?
- Django – “no module named django.core.management”
- ValueError: x and y must be the same size
- Error: “dictionary update sequence element #0 has length 1; 2 is required” on Django 1.4
- OSError: Initializing from file failed on csv in Pandas
- append new row to old csv file python
- NumPy array is not JSON serializable
- You are trying to add a non-nullable field ‘new_field’ to userprofile without a default
- pip install -r requirements.txt [Errno 2] No such file or directory: ‘requirements.txt’
- super(type, obj): obj must be an instance or subtype of type
- Writing a dictionary to a csv file with one line for every ‘key: value’
- Django Rest Framework — no module named rest_framework
- Error: “dictionary update sequence element #0 has length 1; 2 is required” on Django 1.4
- Python Django: You’re using the staticfiles app without having set the STATIC_ROOT setting
- sqlite3.OperationalError: unable to open database file
- TypeError: int() argument must be a string, a bytes-like object or a number, not ‘list’
- Python CSV error: line contains NULL byte
- Django reverse lookup of foreign keys
- ImportError: No module named ‘django.core.urlresolvers’
- How to fix error “ERROR: Command errored out with exit status 1: python.” when trying to install django-heroku using pip
- Python CSV Error: sequence expected
- How to set environment variables in PyCharm?
- AttributeError: ‘float’ object has no attribute ‘split’4
- How to add pandas data to an existing csv file?
- H14 error in heroku – “no web processes running”
- convert csv file to list of dictionaries
- OperationalError: database is locked
- What is a “slug” in Django?
- _csv.Error: field larger than field limit (131072)
- TemplateDoesNotExist at /
- No module named django but it is installed
- What is the easiest way to clear a database from the CLI with manage.py in Django?
- What does on_delete do on Django models?
- Check if an object exists
- Find object in list that has attribute equal to some value (that meets any condition)
- How to check if a user is logged in (how to properly use user.is_authenticated)?
- The view didn’t return an HttpResponse object. It returned None instead
- gunicorn.errors.HaltServer:
django - coercing to Unicode: need string or buffer, NoneType found when rendering in django admin
- coercing to Unicode: need string or buffer, NoneType found when rendering in django admin
- How to query as GROUP BY in django?
- Writing Python lists to columns in csv
- Error loading MySQLdb module: No module named ‘MySQLdb’
- What is related_name used for?
- TypeError: ManyRelatedManager object is not iterable
- What is the most efficient way to store a list in the Django models?
- How to read a CSV file from a URL with Python?
- Line is too long. Django PEP8
- __init__() got an unexpected keyword argument ‘user’
- How to import a csv-file into a data array?