Questions tagged [miller]
Questions about the `mlr` ("Miller") name-indexed data processing tool.
11
questions
3
votes
5
answers
434
views
How to create a new column and add a random identifier to it with miller
I want to add a column with a randomly created "case number" to my csv file. The first 2 letters of the casenumber must be any letter from A-Z in capitals. followed by 5 random numbers.
...
0
votes
3
answers
304
views
Convert lower-case to uppercase with the output to a new column using miller
I want to copy column NAME to column NAME-LOWERCASE. NAME-LOWERCASE should only contain lowercase letters. The uppercase should be untouched in all column expect NAME-LOWERCASE
input
NAME,test
PTC,N
...
0
votes
1
answer
148
views
Forcing miller to read data as string in conversion to JSON
In the following MWE
echo x="1e2" | mlr --ojson cat
my intention is for miller to generate a one-element JSON array containing the object
{"x": "1e2"}
The object ...
6
votes
2
answers
411
views
Deduplicate CSV rows based on a specific column, with a CSV parser
I searched for this task, and found the following older questions:
Removing Duplicates from a CSV based on specified columns
Identify unique records on CSV based on specific columns
But I can't use ...
0
votes
1
answer
330
views
Adding an empty column to a CSV file with Miller
I have a CSV file that looks like this:
0
1
2
3
I'd like to use Miller to append an empty column x to every row so that the output file looks like this:
0,x
1,
2,
3,
How do I do that?
0
votes
1
answer
179
views
Finding whether a string is a substring of another with Miller/mlr's DSL
How do I find whether a column of a CSV contains another using mlr's DSL?
In other words I have a CSV
a,b
test and,test and more
and want to find out whether 'test and' (a) is included in 'test and ...
-2
votes
1
answer
696
views
Separating CSV (one column) into many columns on delimiter (comma) [closed]
I have a CSV with ~50 comma-separated values in one column that I want to separate into separate columns. The header is line 1. This should be really simple, and I've tried a lot surrounding awk and ...
2
votes
3
answers
178
views
Extracting domains from a CSV URL column using Miller
Having CSV content similar to this:
Family,URL,IP,FirstSeen
Pony,http://officeman.tk/images/admin.php,207.180.230.128,01-06-2019
Pony,http://learn.cloudience.com/ojekwaeng/yugo/admin.php,192.145.234....
1
vote
2
answers
195
views
How could I (painlessly) split or reverse "Last, First" within a record in Miller?
I have a tab-delimited file where one of the columns is in the format "LastName, FirstName". What I want to do is split that record out into two separate columns, last, and first, use cut or some ...
6
votes
1
answer
817
views
How can I call an external command from within Miller (mlr)’s DSL?
Suppose I have the following CSV:
$ cat test.csv
id,domain
1,foo.com
2,bar.com
Using mlr put, I can easily map any function over a field in the CSV, as long as I can define it in the Miller DSL. So, ...
5
votes
3
answers
604
views
Output a header label in data field in miller
Given file.csv:
a,b,c
1,2,3
How can mlr be made to output:
a,b,c
1,2,c
Using the label name of $c without knowing in advance that $c contains the letter "c"?
Note: correct answer must use mlr ...