ฉันกำลังพยายามอ่านเล็กน้อ txtname แฟ้มซึ่งจะถูกเพิ่มเป็นโต๊ะเพื่อนค่าปริยาย db บ Databricks. ระหว่างพยายามอ่านแฟ้มผ่านทางท้องถิ่นแฟ้มรูปแบบ api ฉันได้ FileNotFoundError
แต่ฉันสามารถอ่านแฟ้มเดียวกันที่ ออลสปาร์ค RDD ใช้ SparkContext.
ได้โปรดหารหัสด้านล่างนี้:
with open("/FileStore/tables/boringwords.txt", "r") as f_read:
for line in f_read:
print(line)
นี่ทำให้ฉันเกิดข้อผิดพลาด:
FileNotFoundError Traceback (most recent call last)
<command-2618449717515592> in <module>
----> 1 with open("dbfs:/FileStore/tables/boringwords.txt", "r") as f_read:
2 for line in f_read:
3 print(line)
FileNotFoundError: [Errno 2] No such file or directory: 'dbfs:/FileStore/tables/boringwords.txt'
ที่ไหนที่ฉันไม่มีปัญหาการอ่านแฟ้มโดยใช้ SparkContext:
boring_words = sc.textFile("/FileStore/tables/boringwords.txt")
set(i.strip() for i in boring_words.collect())
และอย่างที่คาดหวัง,ฉันเข้าใจที่ผลลัพธ์สำหรับบล็อกของรหัส:
Out[4]: {'mad',
'mobile',
'filename',
'circle',
'cookies',
'immigration',
'anticipated',
'editorials',
'review'}
ฉันยังพูดถึงเรื่อง DBFS เอกสาร ที่นี่ต้องเข้าใจในท้องถิ่นแฟ้มรูปแบบ api ขอ limitations แต่ของไม่มีเบาะแสเกี่ยวกับเหมือนไม่มีปัญหาอยู่เลยสินะ ที่เขาแนะนำให้ผูกผ้ากันเปื้อนจะเป็น greatly นเกียรติอย่างยิ่ง ขอบคุณ!