Я пытаюсь получить файл из hdfs, но он показывает pyspark.errors.Exceptions.capture: [PATH_NOT_FOUND] Путь не существует ⇐ Python
Я пытаюсь получить файл из hdfs, но он показывает pyspark.errors.Exceptions.capture: [PATH_NOT_FOUND] Путь не существует
@app.route('/upload', методы=['POST']) защита загрузки(): глобальный загруженный_df, имя_загруженного_файла если «csv_file» в request.files: csv_file = request.files['csv_file'] если csv_file.имя_файла != '': пытаться: загруженное_имя_файла = csv_file.имя_файла upload_dir = '/data_setu' hdfs_path = os.path.join(каталог_загрузки, имя_загруженного_файла) с hdfs_client.write(hdfs_path, overwrite=True) в качестве записывающего устройства: Writer.write(csv_file.read()) если имя_файла_загружено.endswith('.csv'): df = spark.read.csv(hdfs_path, header=True, inferSchema=True) elif uploaded_filename.endswith('.json'): df = spark.read.json(hdfs_path) elif uploaded_filename.endswith('.parquet'): df = spark.read.parquet(hdfs_path) uploaded_df = df pandas_df = df.toPandas() модифицированный_df_html = Markup(pandas_df.head(55).to_html(classes='table table-bordered table-striped')) return render_template('index.html', columns=pandas_df.columns.tolist(), модифицированный_df_html=modified_df_html) кроме json.JSONDecodeError как e: return f"Ошибка декодирования JSON: {str(e)}" вернуть render_template('index.html') @app.route('/upload', методы=['POST']) защита загрузки(): глобальный загруженный_df, имя_загруженного_файла если «csv_file» в request.files: csv_file = request.files['csv_file'] если csv_file.имя_файла != '': пытаться: загруженное_имя_файла = csv_file.имя_файла upload_dir = '/data_setu' hdfs_path = os.path.join(каталог_загрузки, имя_загруженного_файла) с hdfs_client.write(hdfs_path, overwrite=True) в качестве записывающего устройства: Writer.write(csv_file.read()) если имя_файла_загружено.endswith('.csv'): df = spark.read.csv(hdfs_path, header=True, inferSchema=True) elif uploaded_filename.endswith('.json'): df = spark.read.json(hdfs_path) elif uploaded_filename.endswith('.parquet'): df = spark.read.parquet(hdfs_path) uploaded_df = df pandas_df = df.toPandas() модифицированный_df_html = Markup(pandas_df.head(55).to_html(classes='table table-bordered table-striped')) return render_template('index.html', columns=pandas_df.columns.tolist(), модифицированный_df_html=modified_df_html) кроме json.JSONDecodeError как e: return f"Ошибка декодирования JSON: {str(e)}" вернуть render_template('index.html')
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение