csv-simple

Making single digit numbers between 1 and 9 into double digits, inside CSV file

Making single digit numbers between 1 and 9 into double digits, inside CSV file I have a CSV file with thousands of lines like these 1664;4;5;35;37;43;5;6 1663;21;23;32;40;49;8;11 1662;16;17;34;35;44;5;10 1661;2;9;23;32;40;6;7 1660;23;25;30;44;47;9;12 1659;3;5;9;32;43;6;10 1658;4;6;10;13;34;3;5 1657;8;9;33;35;40;3;6 1656;15;20;31;44;48;1;3 1655;25;27;35;40;45;7;11 1654;7;32;33;34;38;6;9 1653;5;7;11;27;37;6;12 1652;7;31;33;35;36;7;10 1651;4;12;34;35;45;1;9 1650;5;8;29;35;48;5;6 1649;2;11;28;42;48;4;9 1648;2;11;12;19;38;4;8 You can see that the numbers between 1 and 9 are single digit. …

Total answers: 6

Convert json to csv with headers in jq

Convert json to csv with headers in jq Is it possible to convert this json: [ { "bytes": 276697, "checked": false }, { "bytes": 276697, "checked": false } ] to a table WITH headers in jq? I’ve tried: cat file.json | jq ‘.[] | join(",")’ but it omits headers: "276697,false" "276697,false" it should be: "bytes,checked" …

Total answers: 2

Selecting all the records based on filter criteria on 2 fields

Selecting all the records based on filter criteria on 2 fields ABC,1234.5333,5733.9374,5673.352,352,2.346374,-0.6686874 XYZ,5463.674,93773.683,5734.874,432,-5.683423,-10.38393 AES,7436874.5743,937.6843,8464.5634,564,6.35739,10.6834 PQR,784945.464,57484.8647,57484.453,5764,-10.67484,5.74764 From the above csv file , I need to write shell script which will select all the records where the absolute values for any of the last two fields[ ABS(6th field) or ABS(7th field) ] is > = 10. As …

Total answers: 5

Generate the MIN and MAX values for keys derived from multiple fields

Generate the MIN and MAX values for keys derived from multiple fields I have a large flat file which is tab separated and look like this: APP SRC HITS App1 SRC1 202 App1 SRC1 101 App1 SRC13 90 App1 SRC2 3169 App1 SRC4 1 App1 SRC2 158 App1 SRC2 151 App3 SRC3 1 App3 SRC3 …

Total answers: 3

How to exchange matching patterns in a csv file using another two-column csv table

How to exchange matching patterns in a csv file using another two-column csv table I want find patterns from csv1 (column1) in csv2 (anywhere) and exchange them with patterns from csv1 (column2). Like following: -csv1- column1 column2 AA edc BB ysc CC cds DD erg …etc -csv2- column1 column2 column3 …etc (many more columns) BB …

Total answers: 1

Rolling up Multiple Rows into a Single Row

Rolling up Multiple Rows into a Single Row How can I rollup multiple rows from a csv file into 1 row ? I have tried working out the query in SQL and it works but I am not sure how can I achieve the same in Linux. This is how my current file looks : …

Total answers: 5

How can aggregate lines in CSV based on value of one column

How can aggregate lines in CSV based on value of one column My input is the following sorted CSV file (using : as the field delimiter instead of the usual comma): version:device 1.0.0:dev1 1.0.0:dev2 1.2.3:dev3 1.3.4:dev4 1.3.4:dev5 I want to aggregate it so that each version is in 1 line: version:devices 1.0.0:dev1,dev2 1.2.3:dev3 1.3.4:dev4,dev5 Asked …

Total answers: 7

Delete rows from a simplified CSV where some columns matching specific pattern

Delete rows from a simplified CSV where some columns matching specific pattern I have the following simplified CSV file (no separators or newlines embedded in fields): ID,PDBID,FirstResidue,FirstChain,SecondResidue,SecondChain,ThirdResidue,ThirdChain,FourthResidue,FourthChain,Pattern RZ_AUTO_505,1hmh,A22L,C,A22L,A,G21L,A,A23L,A,AA/GA Naked ribose RZ_AUTO_506,1hmh,A22L,C,A22L,A,G114,A,A23L,A,AA/GA Naked ribose RZ_AUTO_507,1hmh,A130,E,A90,A,G80,A,A130,A,AA/GA Naked ribose RZ_AUTO_508,1hmh,A140,E,A90,E,G120,A,A90,A,AA/GA Naked ribose RZ_AUTO_509,1hmh,G102,A,C103,A,G102,E,A90,E,GC/GA Single ribose RZ_AUTO_510,1hmh,G102,A,C103,A,G120,E,A90,E,GC/GA Single ribose RZ_AUTO_511,1hmh,G113,C,C112,C,G21L,A,A23L,A,GC/GA Single ribose RZ_AUTO_512,1hmh,G113,C,C112,C,G114,A,A23L,A,GC/GA Single ribose RZ_AUTO_513,1hnw,C1496,A,G1497,A,A1518,A,A1519,A,CG/AA Canonical ribose RZ_AUTO_514,1hnw,C1496,A,G1497,A,A1519,A,A1518,A,CG/AA …

Total answers: 3