python - 有没有办法确定文本文件中多行字段的最佳引号字符?
问题描述
我有一个带有多行的 foobar.txt 文件,如下所示:
|a_column|;|b_xml_column|
|first_value|;|my second value
still line 1
still line 1
still line 1
still line 1
still line 1
still line 1
still line 1|
|my third value|;|the end|
我要阅读的火花代码:
spark.read\
.option("header", "true")\
.option("multiLine", "true")\
.option("delimiter", ";")\
.option("quote","|")\
.csv("foobar.txt").show(2, False)
输出:
但是在现实世界的场景中b_xml_column
, 甚至中可能存在任何字符|
,这将导致多行读取失败,那么,确定quote
这些字段的分隔符的最佳方法是什么?阅读时永远不会失败的那个。
解决方案
推荐阅读
- javascript - 单击包含跨度的 div,不会触发 onclick 事件 - React
- javascript - 在将 clickTag 用于 HTML5 展示广告时将搜索参数添加到 url
- r - 构建 Docker 映像并指定端口后,闪亮的应用程序未显示
- excel - 运行“Workbook_Open()”后关闭工作簿
- java - 使用 mapbox 时尝试在空对象引用上调用虚拟方法“double android.location.Location.getLatitude()”
- c# - 在与控制器不同的表中插入生成的主键作为外键
- python-2.7 - 使用子进程捕获 jupyter-notebook 标准输出
- c++ - 如何发送原始 JSON Post 请求 C++
- c++ - 在 Solaris 11 上使用 g++ 5.4 编译时未在 Solaris 10 上捕获 C++ 异常
- android - 试图从活动 1 获取字符串值到活动 2 的片段,但它返回为 null。GetArgument 始终返回为 null