Comments (7)
Hi there!
Does this provide the expected output?
while true; do
date | jc —date
sleep 1
done
from jc.
Suure. But I do not control how is the stream of dates generates. That was just an example/reproduction to motivate this issue.
from jc.
Gotcha. I’d have to play around with it but can’t get to it for a few days - not sure if it’s possible in a stream you don’t control. There are a few parsers that support streams (like ping-s
) but the date
parser is not one of them.
You could implement a plugin parser (e.g. date-s
. You could take a look at how the other streaming parsers are done and do something similar.
from jc.
No hurry. I think it would be nice if any plugin could be converted to a stream one by simply reapplying it again and again on the stream. But probably that would require from each plugin to have a concept of chunks.
from jc.
That would definitely work for the parsers that work on a single line of text like date
. Like you mentioned, would require more thought for other parsers.
from jc.
I got some inspiration from your blog post and made regex2json tool which allows conversion of test-based data into JSON by just providing a regex. So similar to how jc works, but for more ad-hoc use cases where you write the pattern as CLI argument. And it also operates on line-to-line. This I think nicely works together with the jc tool and other tools operating on JSON. I think piping JSON lines instead of text lines between processes is really powerful.
So the example above could then be:
$ while true; do LC_TIME=C date; sleep 1; done | regex2json "(?P<date___time__UnixDate__RFC3339>.+)"
{"date":"2023-06-13T11:26:45Z"}
{"date":"2023-06-13T11:26:46Z"}
{"date":"2023-06-13T11:26:47Z"}
from jc.
This is fantastic! Very cool tool. I’ll link to it in the readme in the next release.
from jc.
Related Issues (20)
- iwconfig parser don't work HOT 9
- /proc/pid/state parser add missing state 'I' HOT 2
- jc --rsync, it should be able to parse the summary of rsync, but doesn't work HOT 5
- New parser: php-fpm8.2 -tt HOT 2
- PostgreSQL INI files HOT 2
- xrandr fails to parse disconnected output, that is still enabled HOT 3
- iptables fails to parse -x (expand numbers) option because "pkts" header has more than one leading blank HOT 5
- Add `--locale` option to specify fallback encoding to decode `data_in` with HOT 1
- `lspci` parser PhySlot issue HOT 4
- Fix documentation for apt-get-sqq parser HOT 3
- New Parser - NUT-upsc command HOT 1
- [parsers /pci_ids.py] Only last [subvendor][subdevice] got loaded into result when multiple subdevices having the same subvendor id HOT 3
- Bug: Traceroute ignored IPs when multiple IPs on hop HOT 3
- "ss" Parser not working correctly: Entries Missing HOT 5
- .netrc support HOT 1
- Problem with --pip-show parser for a module with nothing on the License: line but which has following lines HOT 4
- lspci strips trailing digit on bus ID HOT 3
- `--zpool-status` fails to handle the `spares` section of `zpool status` HOT 3
- New parser request: pacman -Si HOT 2
- 1.25.3: pytest fails in nits which are comparing time HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jc.