我有我想要使用Python,它具有類似於以下行來讀取一個CSV:與Python閱讀CSV打破在方括號
10x org il,"["Modiin, Israel"]","["no current price posted"]","["Modiin: no current size posted"]","{ "Python Bootcamp": {"Price: ","["http://www.10x.org.il/"]","[{ "j": 31.9077, "C": 35.0076 }]"
,但它打破上的第一方括號這樣的:"[{ "j": 31.9077, "C": 35.0076 }]"
與SyntaxError: invalid syntax
我用下面的Python讀取文件錯誤信息:
import csv
with open('programming_bootcamps_csv.csv', 'rb') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print(row["campName"])
我已經通過了一些文檔閱讀關於爲什麼方括號會打破這一點,並且沒有就什麼問題或如何解決問題得出任何結論。
您是否嘗試過使用csv.reader()而不是DictReader? –
查看代碼突出顯示SO自動應用:其中一個逗號引號圍繞它,反轉了其餘內容的引用狀態。這會造成格式不完整的CSV文件。 – TigerhawkT3
我打開這條線成三引號的字符串和'計數(「「」)''返回27'。檢查文件,確保所有的報價都匹配,等等。 – TigerhawkT3