2
我想運行一個小腳本來讀取兩列CSV,轉換爲JSON,併發送到服務。該代碼應該是相當直接的,我認爲:我的JSON解析不正確。我究竟做錯了什麼?
#read excel
df = pd.read_csv('C:\\Users\\Admin\\Desktop\\CSV_1.csv')
# Randomly sample 3% of your dataframe
df_10 = df.sample(frac=0.03)
#convert excel to json for testing
json_file=df_10.to_json()
source = json.loads(json_file)
for row in source:
player = row[0]
team = row[1]
的問題是,行[0]和行[1]似乎是在我的CSV的每一列的第一個字符....不完整行。我的CSV最初的格式是
Player, Team
我解析我的JSON不正確,或者如何在這裏讀取正確的數據?
謝謝。