Web Scraping and Text Analysis
9
|How to Format Results in a Grid
Introduction
List structure, with curly brackets, is useful for analysis. But it is sometimes preferable to display results in a nicely formatted grid to make the results easier to read.
How to Display a List in Grid Format
How to Display a List in Grid Format
Many commands are available to format results. The TextGrid function will create a more spreadsheet-like result, so it is easier to read. This can be a mix of text that acts as a label and symbols calculated in the previous chapter:
In[]:=
grid=TextGrid[{{"Number of people words:",findPeople},{"Number of number words:",findNumber}},Frame->All]
Out[]=
Number of people words: | 3 |
Number of number words: | 25 |
In addition to TextGrid, Wolfram Language contains other functions that can be used for formatting, like Column, Row, Grid or TableForm. These functions can work with a mixture of text, numeric values and images. The following adds a word cloud to the formatted result, in addition to the count of keywords above.
The symbol web4 was defined in an earlier chapter:
In[]:=
Column[{WordCloud[web4],grid}]
Out[]=
|
The function Column also has optional arguments to create a frame. So adding a frame to the Column structure displays a border around the TextGrid as well as the word cloud:
In[]:=
Column[{WordCloud[web4],grid},Frame->All]
Out[]=
|
Summary
Summary
Mathematica can export results to a spreadsheet format, an image format or over a hundred other external file formats. When creating an analysis, it might be preferable to share an entire Mathematica notebook in PDF form, as a website or in computable form. In any case, Wolfram Language can format results very nicely without using additional software solely for presentation of results.