Search for '{{search_term}}'

Exercise: parse variable width fields

CMOS is the Code-Maven Open Source podcast that also includes video interviews. Subscribe to this feed RSS feed with your Podcast listener app or via iTunes iTunes.

Exercise: parse variable width fields

In this log file I got from some company, there are rows in which the first 16 and last 16 characters describe some kind of an addresses while everything in between describes several commands.

Each command is built up by a leading character (A, B, C, D, etc) and a number of digits. The number of digits depend on the leading character.

In this exercise we need to split up the data to commands and count how many times each command type was given.

examples/data/variable_width_fields.log

1234567890123456A001B0002D00004C0000051234567890123456
1234567890123456A001A002D00004C0000051234567890123456

Tools

Solutions

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus