Pretty print tables into text forms

Hello,

In robotics you frequently encounter use cases where you read a table from a page (HTML, XLS) in nicely aligned graphical format, but then after working on it you need to post the resulting table in another application into a plain text form. There it becomes almost unreadable due to the misalignment of the columns.

It would be great if there was a ‘Pretty print’ activity that could be used to print a table into a first character aligned text (like old command line apps could do).
Tabbed text out won’t cut it, as you have variable length words that overflow on tab boundaries.

I could envision this feature as an enhancement to the current ‘Output Data table’ activity, where you can click this alignment as an option, and also to drop the first row which you get when you read something from a web table, and reads Column-0, Column-1…

Hi @zbalint

I have recently seen this topic:

But the general notion I get here is that tools like the one above (or similar) could do much more than Studio/activities can output in the Output pane.

But maybe it’s just me, let’s see what other people think :slight_smile:

3 Likes

Not sure that we understood each other here.
My problem is that I have to output data from tables into a text form (plain text) and I would like to do that in a way so that table columns are still vertically aligned for each row. Simple tabbed text does not work well due to variable length values that exceed the tab size.

In the past some old networking kit had software that could print a table on the console so that it was nice to read. These days most applications have built-in tables, but when you need to post information in a text form, then you are out on options.

In this case the robotic activity would need to take in all the input table, and calculate per row the max characters per ‘cell’ and set the whole alignment of all rows so that there is some space left between columns even for the longest words.

Yes, indeed, I think I got it right.
My argument here would be that there is most likely enough CSV Beautifiers out there that there is no real need to have this feature in Studio, given that it could hardly match the available solutions.

But it’s just my guess and this is why it is nice to have a discussion here :slight_smile:
If more people say “we want it”, it will happen :smiley:

The program you linked does not really do this.

Can you point to a .Net plugin/code that can do what this site does?
https://plaintexttools.github.io/plain-text-table/

I would like the ‘OutputDataTable’ activity to do this, but a loadable library would also be fine.

Interesting thought. I made a quick mockup with something I found on nuget.org:

I marked the name of the package.

The issue here is that each line is treated separate in the log, so you can’t really copy it. But I suppose you could write it to a file instead :slight_smile:

It’s this one: GitHub - minhhungit/ConsoleTableExt: A fluent library to print out a nicely formatted table in a console application C#

1 Like

Great, this is a workable and reasonably simple solution!
Thanks for posting the code clearly.
For others who would want to use this, beware: the output may seem misaligned on the UIPath console, as that does not use fixed with characters. If you copy the thing over into a notepad then the columns align nicely.

1 Like

Chaps, in the spirit of giving back, I am posting the code that will be able to return what was printed into a variable:
out_MyCodeConsoleTableText=ConsoleTableExt.ConsoleTableBuilderExtensions.Export(ConsoleTableExt.ConsoleTableBuilder.From(in_MyCodeDt)).ToString

And a sample workflow:
PrintToConsoleTable.xaml (5.8 KB)

Improvements to the workflow welcome: one fairly useful extra would be if the user could pass the ‘style’ as a parameter. The original library supports multiple table styles.

Many thanks again for the help I received from the community: It’s a real pleasure to come around here!

1 Like