Tagged Questions
2
votes
2answers
412 views
Is there a command line utility to transpose a csv-file?
Given a file like so
First, Last, Age
Cory, Klein, 27
John Jacob, Smith, 30
Is there a command line utility to transpose the contents so the output appears like so
First, Cory, John Jacob
Last, ...
4
votes
4answers
445 views
A unix command to truncate each line of a file
I have a CSV file and I want to truncate it from the third semicolon. For example, if I have this file:
1;foo;bar;baz;x;y;z
2;foo;bar;baz;x;y;z
3;foo;bar;baz;x;y;z
I want to get the following ...
2
votes
3answers
1k views
Extracting column from comma separated text
I have a long comma-separated delimited file with 20K lines. Here's a sample:
"","id","number1","number2","number3","number4","number5","number6","number7"
...
7
votes
5answers
2k views
Remove comma between the quotes only in a comma delimited file
I have a input file delimited with commas (,). There are some fields enclosed in double quotes that are having a comma in them. Here is the sample row
123,"ABC, DEV 23",345,534.202,NAME
I need to ...
2
votes
1answer
265 views
Regarding generating intersection and union of two csv files
I have two csv files, there are some overlap columns between these two files. Assume one file is called as A.csv and another is called as B.csv. The intersection of A and B is called as C.
I would ...
3
votes
3answers
312 views
Using CSV line as command parameters
I have a CSV file like:
Name,Age,Address
Daniel Dvorkin,28,Some Address St. 1234
(... N ...)
Foo Bar,90,Other Address Av. 3210
And I have a command that take this parameters:
./mycommand ...
2
votes
1answer
850 views
Swap two columns in a CSV using SED
I have a CSV file that contains 10 different fields (, is the deliminator). Example data:
student-id,last,first,hwk1,hwk2,hwk3,exam1,hwk4,hwk5,exam2
pts-avail,,,100,150,100,200,150,100,300
...
2
votes
6answers
2k views
How to swap columns in such a file?
I have a text file, each line is stored like this :
"Video or movie" "parent" "Media or entertainment" "1" "1" "1" "0" "0"
I want to swap the columns 3 with 2, i.e.
"Video or movie" ...
3
votes
2answers
262 views
need shell script to grock a csv
Need some pointing in right direction on script to fetch and regex or sed.
Site24x7 provides a URL with a CSV list of their source IP's used for monitoring. (they also provide other formats, CSV ...
6
votes
2answers
1k views
sort inplace - like sed --in-place - exists?
Am I blind or is there no option like --in-place for sort?
In order to save results to the input file, sed uses -i (--in-place).
Redirecting the output of sort to the input file
sort < f > f
...
3
votes
1answer
100 views
Wrapping long cells in a tsv to keep them in same column
Formatting a TSV with long cells with column makes its readability very low. It simply breaks lines like this:
$ python3 -c 'for i in (1,2,3): print(((str(i)*50)+"\t")*3)' | column -s $'\t' -t
...
3
votes
1answer
303 views
How to display TSV (csv) in console, when empty cells are missed by: `column -t -s $'\t' `
I have file with columns spearated with tab.
I have file when some rows have empty cells (on begining, in middle).
In such cases column -t -s $'\t' simply fails:
Input:
$ echo -e ...
4
votes
6answers
2k views
How can I convert tab delimited data to comma delimited data?
I'm requesting a list of ec2 snapshots via amazon's ec2 command line tool:
ec2-describe-snapshots -H --hide-tags > snapshots.csv
The data looks something like this:
SnapshotId VolumeId ...
14
votes
5answers
1k views
Command line friendly spreadsheets
Does such a thing exist? Text-based spreadsheets that display well in a CLI environment. I'm aware that I could cat foobar.csvand do as I please, but it isn't particularly practical or attractive. I ...
2
votes
4answers
2k views
How can I find and replace with a new line?
I have a CSV delimited by commas and I want to delimit it by newlines instead.
Input:
a, b, c
Output:
a
b
c
I've written Java parsers that do this stuff, but couldn't this be done with vim or ...
5
votes
3answers
1k views
command to layout tab separated list nicely
Sometimes, I'm getting as an input tab separated list, which is not quite aligned, for instance
var1 var2 var3
var_with_long_name_which_ruins_alignment var2 var3
Is there an easy way to render ...
13
votes
8answers
2k views
Is there a robust command line tool for processing csv files?
I work with CSV files and sometimes need to quickly check the contents of a row or column from the command line. In many cases cut, head, tail, and friends will do the job; however, cut cannot easily ...
