[英]Databricks - Writing CSV as a Parquet folder even when specified as a CSV file
[英]Writing a user specified folder structure to csv in Python
好的,這是完成工作的代碼:
import os
import csv
data = []
for root, dirs, files in os.walk('.'):
for f in files:
l = root.split('/') + [f]
data.append(l)
with open('output.csv', 'wb') as f:
writer = csv.writer(f)
for d in data:
writer.writerow(d)
如果您使用的是Windows,請將split('/')
替換為split('\\\\')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.