web analytics
364 NEWS
No Result
View All Result
Wednesday, May 25, 2022
  • Login
  • Home
  • World
  • Economy
  • Business
  • Markets
  • Tech
  • Real Estate
Subscribe
364 NEWS
  • Home
  • World
  • Economy
  • Business
  • Markets
  • Tech
  • Real Estate
No Result
View All Result
364 NEWS
No Result
View All Result
Home Tech

Show HN: utt, the Universal Text Transformer

by admin
March 7, 2022
in Tech
0
Show HN: utt, the Universal Text Transformer
152
SHARES
1.9k
VIEWS
Share on FacebookShare on Twitter

utt is the universal text transformer. utt is intended for
converting between textual data representations. For example, utt can be used
to convert from JSON to YAML:

$ echo "[1, 2, 3]" | utt -i json -o yaml
---
- 1
- 2
- 3

$ 

Formats may be supported for input-only or output-only. You can see all
supported formats by running utt with no arguments.

Note: “universal” is a big claim, and I understand that utt isn’t truly
universal. However, it is an active goal to work on supporting more and more
formats and transformations to make utt as close to truly universal as
possible.

Getting it

A UNIX-compatible binary is automatically released here: https://github.com/queer/utt/releases.
This binary is just:

utt && cat utt-*.jar >> utt && chmod +x utt”>

$ echo "#!/usr/bin/env -S java -jar" > utt && cat utt-*.jar >> utt && chmod +x utt

On Windows, run mvn clean package to create a JAR file in target/.

What and why

utt (case-sensitive) is a tool for converting between textual data formats. utt
was originally written for a project that involved a lot of annoying
conversions, to the point where one-off scripts wouldn’t be enough.

utt makes some tradeoffs in the name of functionality. For example, utt does
not process data in a streaming manner, but rather loads the entire dataset
into memory before processing. In exchange, utt is more flexible in what it
accepts as input and output formats. For example, utt can only output to CSV by
iterating over the input data to determine the output schema.
Similarly, utt’s mapping functionality relies on the GraalVM Polyglot API,
which has a high (~500ms) startup time.

Examples

Convert from JSON to YAML

$ echo '{"key": [1, 2, 3]}' | utt -i json -o yaml
---
key:
- 1
- 2
- 3

$

Extract keys from a JSON object

$ echo '[{"key": 1}, {"key": 2}, {"key": 3}]' | utt -i json -o json -M '_.key'
[1.0,2.0,3.0]
$

Flatten a list

$ echo '[[1], [2], [3]]' | utt -i json -o json -F
[1.0,2.0,3.0]
$

Encode text with base64

$ echo "this is a test" | utt -i plain -o base64
dGhpcyBpcyBhIHRlc3Q=
$

Extract inner values and flatten

$ echo '{"key": [1, [2], [[3]]]}' | utt -i json -o json -M '_.key' -F
[1.0,2.0,3.0]
$ 

Extract a JSON array from an XML object

cccc” | utt -i xml -o json -M ‘$.b’
[“c”,”c”,”c”,”c”]
$”>

$ echo "cccc" | utt -i xml -o json -M '$.b'
["c","c","c","c"]
$

Apply a map function to the values of a list

$ echo "[1,2,3]" | utt -i json -o yaml -M "_ * 2"
---
- 2.0
- 4.0
- 6.0

$

Read More

Tags: TransformerUniversal
  • Trending
  • Comments
  • Latest
Does omicron cause unusual symptoms?

Does omicron cause unusual symptoms?

December 13, 2021
One person dead following incident at SilverStar Mountain Resort

One person dead following incident at SilverStar Mountain Resort

December 20, 2021
Edmonton Police helping families in need through Holiday Heroes campaign

Edmonton Police helping families in need through Holiday Heroes campaign

December 20, 2021
Amazon staff had to use bathrooms as tornado shelters

Amazon staff had to use bathrooms as tornado shelters

December 13, 2021
Hashtag Trending Dec. 8 – Massive numbers of YouTube copyright strikes; Microsoft seizes hacker’s servers; Outage at AWS

Hashtag Trending Dec. 8 – Massive numbers of YouTube copyright strikes; Microsoft seizes hacker’s servers; Outage at AWS

0
With Stimulus Benefits Ending, What Should Small Business Owners be Aware of?

With Stimulus Benefits Ending, What Should Small Business Owners be Aware of?

0
7 Ways to Be a Truly Customer-Focused Business

7 Ways to Be a Truly Customer-Focused Business

0
Assumptions Can Hold Your Company’s Success Hostage. Here’s How to Fight Them

Assumptions Can Hold Your Company’s Success Hostage. Here’s How to Fight Them

0
Bay Area antisemitic leader allegedly spotted terrorizing guests at Beverly Hills Hilton

Bay Area antisemitic leader allegedly spotted terrorizing guests at Beverly Hills Hilton

May 25, 2022
PayPal lays off 83 San Francisco Bay Area employees

PayPal lays off 83 San Francisco Bay Area employees

May 25, 2022
Robots are taking over China’s warehouses

Robots are taking over China’s warehouses

May 25, 2022
Ultimate Frisbee soars in China — as a fashion sport

Ultimate Frisbee soars in China — as a fashion sport

May 25, 2022
  • Home
  • Advertisement
  • Contact Us
  • Privacy & Policy
  • Other Links

© 2021 364News - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Advertisement
  • Contact Us
  • Homepages
    • News 364
  • World
  • Economy
  • Business
  • Opinion
  • Markets
  • Tech
  • Real Estate

© 2021 364News - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In