python - 在 python 中找不到 azure 中的目录或文件
问题描述
我在python中做了一个脚本,在本地执行成功但是在azure中没有找到方法,我用pyspark做了一个测试只是为了看看它是否找到了方法并找到了但是我不知道pyspark把这段代码变成pyspark,如何我要访问 azure 中的目录吗?
import csv
from datetime import datetime
origem ='/mnt/caminho/teste.txt'
destino = "/mnt/caminho/teste.csv"
print(origem)
print(destino)
try:
with open(origem, "r", encoding="UTF-8") as ler, open(destino, mode='w', encoding='UTF-8') as gravar:
next(ler)
next(ler)
gravar.writelines(['data_puxada;','centro;','atribuicao;','ped_pca;','transporte;','fornecimento;','codigo_material;','descr_produto;','descr_status_pedido;','quantidade;','hora_puxada;','cliente;','cliente_sap;','numero_nota_fiscal;','data_inicio_carregamento;','hora_inicio_carregamento;','dt_termino_carregamento;','hora_termino_carregamento;','numeroov_pedtransf;','can_distrib;','tipo_operacao;','tipo_operacao;'])
gravar.write('\n')
next(ler)
next(ler)
for linha in ler:
if len(linha.strip()) > 0 and len(linha.strip("ഀ").strip()) > 0:
linha = linha.rstrip()
gravar.writelines(linha.replace('\t',';').strip()[:-2].rstrip()[1:].replace(".",'/',2).replace(".","",10))
gravar.write('\n')
#print(linha)
except AttributeError:
print("Erro")
解决方案
我设法访问,添加/dbfs/,所以它看起来像这样/dbfs/mnt/caminho/teste.txt
推荐阅读
- loops - 如何获取数据库中所有列的最小值、最大值和总和?
- apache-spark - 如何解决 java.net.ConnectException:连接被拒绝错误
- google-app-engine - 我的 appengine 标准 (java11) 上的第一个请求的响应时间长(+40 秒)
- python - 为什么我的脚本在 n 次后停止输出?
- r - Spacyr 未初始化以运行 NER
- java - 我在 jitpack 中将我的依赖版本作为 Tag 而不是 1.0 ..?
- java - 警告:org.xerial 的 sqlite-jdbc 未加载
- ssl - 使用 pip3 和 python 安装软件包时出现问题 (ReadTimeoutError / SSLError(SSLCertVerificationError)
- c# - ASP.NET Core 模拟服务仅在一个请求的范围内
- php - 如果客户购买了一些特定的产品,那么我想将其他条件放入其中