Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
I can't read the csv into pandas. The file that i'm trying to import has text and data, but I only want the data.
I've tried the following
df = pd.read_csv(csv_file, sep=" ", header=None, names=["col1","col2","col3"], skiprows = 2) to try to remove the comments and just read the numbers
Error: pandas will not read all 3 columns. It only reads 1 column
I tried df = pd.read_csv(csv_file, sep="\s{2}", sep=" ", header=None, names=["col1","col2","col3"], skiprows = 2) to try to remove the comments and just read the numbers
Error: cannot use a string pattern on a bytes-like object
I tried df = pd.read_csv(csv_file.read(), sep=" ", header=None, names=["col1","col2","col3"], skiprows = 2) to try to remove the comments and just read the numbers
Because sep is more than one character, you need to use the python engine instead of the C engine. The python engine sometimes has trouble with quotes, but you don't have any, so that's fine. You actually don't even need to specify the python engine, it will be selected automatically for you, but you'll get a warning to stderr; specifying the engine suppresses that.
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that
you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice
sessions to improve your knowledge and scores.
manpreet
Best Answer
2 years ago
I'm building a web app using Django. I uploaded a text file using
csv_file = request.FILES['file'].
I can't read the csv into pandas. The file that i'm trying to import has text and data, but I only want the data.
I've tried the following
Error: pandas will not read all 3 columns. It only reads 1 column
Error: cannot use a string pattern on a bytes-like object
File I uploaded
views.py