我正在尝试上传CSV文件,并使用Pandas读取它,然后将一列数据添加到该CSV文件中。但是,我收到一个错误pandas.errors.EmptyDataError:没有要从文件解析的列
@app.route("/success", methods=["POST"])
def success():
global file
if request.method=="POST":
file=request.files["file"]
file.save(secure_filename("uplodovano"+file.filename))
podaci=pd.read_csv(file, index_col="Rbr")
df=pd.DataFrame(podaci)
while True:
try:
if "Adresa" in df.columns:
df1=df["Adresa"]
lst=[]
for i in df1:
g1=geocoder.google(i)
g2=g1.latlng
lst.append(g2)
df["Koordinate"]=lst
df.to_csv("izvezeno.csv")
print(df)
break
elif "adresa" in df.columns:
df1=df["adresa"]
lst=[]
for i in df1:
g1=geocoder.google(i)
g2=g1.latlng
lst.append(g2)
df["Koordinate"]=lst
df.to_csv("izvezeno.csv")
print(df)
break
else:
print("Ne postoje podaci o adresama. Please check CSV fajl!!!!!!")
break
except KeyError:
break
return render_template("index.html", btn="download.html")@app.route("/success", methods=["POST"])