对控制台友好的等效于show()的将文本包装在列中

时间:2019-01-11 19:09:41

标签: scala apache-spark apache-spark-sql

我经常使用dataframe.show()以易于理解的方式将表格数据输出到控制台。谁能建议一个等效于show()的支持列内自动换行的东西?

Seq(
  ("a very large amount of text", 256),
  ("a really large amount of text", 15015),
  ("a an absolutely enormous amount of text, too much to contain in one line", 2131)
).toDF("word", "count").show(false)

+------------------------------------------------------------------------+-----+
|word                                                                    |count| +------------------------------------------------------------------------+-----+
|a very large amount of text                                             |256  |
|a really large amount of text                                           |15015|
|a an absolutely enormous amount of text, too much to contain in one line|2131 | +------------------------------------------------------------------------+-----+

I would prefer something that will return:

+-----------------------------------------------+-----+
|word                                           |count|
+-----------------------------------------------+-----+
|a very large amount of text                    |256  |
+-----------------------------------------------+-----+
|a really large amount of text                  |15015|
+-----------------------------------------------+-----+
|a an absolutely enormous amount of text,       |131  |
|too much to contain in one line                |     |
+-----------------------------------------------+-----+

0 个答案:

没有答案