Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I have trouble reading this csv file downloaded from kaggle. I have tried using the utf-8 encoding and it was still not able to read the csv file
There might be some special characters in the file.
import pandas as pd
df = pd.read_csv(r"file_path", encoding="latin1")
with open('filename.csv') as file_info:
print(file_info)
The encoding will be at the end.
data=pd.read_csv('filename.csv', encoding="encoding from file_info")
Works every time.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
import pandas as pd
data = pd.read_csv("prices.csv")
data.index = pd.to_datetime(data['Date'])
I changed the header in the csv file to 'Date' but still got the key error. Does anyone know what to do?
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am trying to use Glob to get files in a directory. I am learning how to use it through this. My code should (so far) be able to print out all of the files in the files directory. But instead it is just printing out ['files'].
My code is at #EvokerKing/JSON on repl.it.
I guess you want to do this
import json
import glob
fileList = glob.glob("files/*")
print(fileList)
for finding the files under files folder you need to use files/*
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have tried looking this up, but for some reason I cannot find anything about it. How do I run a script by giving the particular file directory in start()?
This works (when Test is in the same folder as the main script):
self.process.start("python3 Test.py")
This does NOT work:
self.process.start("python3 /my/path/Test.py")
Try this:
self.process.start("python3 ../my/path/Test.py") # added two periods before "/m"
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Hello I am trying to scrape a website and its going fine, till the point I try to save the data into a csv via csv module writer. I traced back to the data and find out that 7 aƱos is the string which isn't allowing the data to store properly.
I READ A LOT ON THIS TOPIC BEFORE POSTING... BUT COULDN'T GRASP THE CONCEPT.
Python is throwing some encoding error which got me to reading and I found that csv module isn't capable of unicode.
Is there any suggestion?
Try to use following solution
def sanitize_string(string):
return string.replace('\t', '')
Try to encode the string using encode function
your_variable = sanitize_string("your string")
your_variable.encode('utf8')
Hope this will help you.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a folder of CSV files that I need to edit. Each file has a blank line in the middle. I want to take everything under that blank line and put it into a new excel sheet while rewriting my CSV file to a xls file. How can I do this?
A quick Google search revealed the openpyxl library that you can use to create XLS files.
Reading CSV is built into Python.
The rest is a simple matter of programming :) If you run into a more specific problem, please feel free to post a new question.