ich eine Textdatei lese die Daten in diesem Format hat:split - Valueerror: Notwendigkeit, mehr als 1 Wert auspacken
column : row
Dies ist einige Daten Beispiel:
Name of the Property : North Kensington Upcycling Store and Cafe
Availability : Now
Interest Level : 74 people are looking right now
Area : 1,200 sqft
Retail Type : No
Bar & Restaurant Type : No
Mein Code gibt dieser Fehler:
ValueError: need more than 1 value to unpack
auf dieser Linie:
k,v = txt_line.split(":")
Mein Code:
import pandas
txt_file = r"patty.txt"
txt = open(txt_file, "r")
txt_string = txt.read()
txt_lines = txt_string.split("\n")
txt_dict = {}
for txt_line in txt_lines:
print(txt_line)
k,v = txt_line.split(":")
k = k.strip()
v = v.strip()
if k in txt_dict:
list = txt_dict.get(k)
else:
list = []
list.append(v)
txt_dict[k]=list
print (pandas.DataFrame.from_dict(txt_dict, orient="index"))
I versucht, es mit minimalen Daten laufen zu lassen sagen nur die ersten 3 Zeilen und ich bekomme immer noch den Fehler..am mache ich etwas falsch mit der Logik hier? – roy