Как я неправильно использую сортировку?

У меня есть очень маленький файл bugtest.csv с годами в седьмом столбце. Его содержимое гласит:

1000,101,1,2,"VEN","Venezuela, Bolivarian Republic of",1967,22,4,99,0,0,1967-12-07,"R/22/2328A",0,1,"PRIVILEGES AND IMMUNITIES","TO ADOPT OPERATIVE PARAG. 2 OF DRAFT RESOL. (A/6965) ON DIPLOMATIC PRIVILEGES AND IMMUNITIES, WHICH PARAGRAPH URGES U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON PRIVILEGES AND IMMUNITIES.",0,0,0,0,0,0,0,22027
1000,713,1,1,"TWN","Taiwan, Province of China",1967,22,4,99,0,0,1967-12-07,"R/22/2328A",0,1,"PRIVILEGES AND IMMUNITIES","TO ADOPT OPERATIVE PARAG. 2 OF DRAFT RESOL. (A/6965) ON DIPLOMATIC PRIVILEGES AND IMMUNITIES, WHICH PARAGRAPH URGES U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON PRIVILEGES AND IMMUNITIES.",0,0,0,0,0,0,0,22027
100,101,1,2,"VEN","Venezuela, Bolivarian Republic of",1948,3,9,6,37,0,1948-11-07,"R/3/566C",0,1,"DISARMAMENT, NUCLEAR","TO ADOPT PARAGRAPH 7 OF THE USSR DRAFT RESOL. (A/723), SAID PARAGRAPH RECOMMENDING THE PROHIBITION OF ATOMIC WEAPONS INTENDED FOR AGGRESSION.",0,1,1,0,0,0,0,3023
1001,101,1,1,"VEN","Venezuela, Bolivarian Republic of",1967,22,1,101,0,0,1967-12-07,"R/22/2328B",0,0,"PRIVILEGES AND IMMUNITIES","TO ADOPT DRAFT RESOL. (A/6965) URGING U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON (DIPLOMATIC) PRIVILEGES AND IMMUNITIES AND DEPLORING ALL DEPARTURES FROM THE RULES OF INTERNATIONAL LAW ON THE SUBJECT.",0,0,0,0,0,0,0,22028
1001,713,1,1,"TWN","Taiwan, Province of China",1967,22,1,101,0,0,1967-12-07,"R/22/2328B",0,0,"PRIVILEGES AND IMMUNITIES","TO ADOPT DRAFT RESOL. (A/6965) URGING U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON (DIPLOMATIC) PRIVILEGES AND IMMUNITIES AND DEPLORING ALL DEPARTURES FROM THE RULES OF INTERNATIONAL LAW ON THE SUBJECT.",0,0,0,0,0,0,0,22028
1002,101,1,3,"VEN","Venezuela, Bolivarian Republic of",1967,22,11,50,51,0,1967-12-07,"R/22/2338A",1,1,"INTERNATIONAL YEAR FOR HUMAN RIGHTS","TO ADOPT THE AMENDMENT (A/L. 542) TO DRAFT RESOL. (A/7008) ON \INTERNATIONAL YEAR FOR HUMAN RIGHTS\\, WHICH AMENDMENT DELETES OPERATIVE PARAG.10.\""""",0,0,0,1,0,0,0,22029

Я хочу отсортировать его по году (7-й столбец). Я пытаюсь:

sort -o Votes2.csv -t, -nk7 bugtest.csv 

, но он ведет себя так, как будто файл уже был отсортирован. Другими словами, выходной файл гласит:

1000,101,1,2,"VEN","Venezuela, Bolivarian Republic of",1967,22,4,99,0,0,1967-12-07,"R/22/2328A",0,1,"PRIVILEGES AND IMMUNITIES","TO ADOPT OPERATIVE PARAG. 2 OF DRAFT RESOL. (A/6965) ON DIPLOMATIC PRIVILEGES AND IMMUNITIES, WHICH PARAGRAPH URGES U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON PRIVILEGES AND IMMUNITIES.",0,0,0,0,0,0,0,22027
1000,713,1,1,"TWN","Taiwan, Province of China",1967,22,4,99,0,0,1967-12-07,"R/22/2328A",0,1,"PRIVILEGES AND IMMUNITIES","TO ADOPT OPERATIVE PARAG. 2 OF DRAFT RESOL. (A/6965) ON DIPLOMATIC PRIVILEGES AND IMMUNITIES, WHICH PARAGRAPH URGES U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON PRIVILEGES AND IMMUNITIES.",0,0,0,0,0,0,0,22027
100,101,1,2,"VEN","Venezuela, Bolivarian Republic of",1948,3,9,6,37,0,1948-11-07,"R/3/566C",0,1,"DISARMAMENT, NUCLEAR","TO ADOPT PARAGRAPH 7 OF THE USSR DRAFT RESOL. (A/723), SAID PARAGRAPH RECOMMENDING THE PROHIBITION OF ATOMIC WEAPONS INTENDED FOR AGGRESSION.",0,1,1,0,0,0,0,3023
1001,101,1,1,"VEN","Venezuela, Bolivarian Republic of",1967,22,1,101,0,0,1967-12-07,"R/22/2328B",0,0,"PRIVILEGES AND IMMUNITIES","TO ADOPT DRAFT RESOL. (A/6965) URGING U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON (DIPLOMATIC) PRIVILEGES AND IMMUNITIES AND DEPLORING ALL DEPARTURES FROM THE RULES OF INTERNATIONAL LAW ON THE SUBJECT.",0,0,0,0,0,0,0,22028
1001,713,1,1,"TWN","Taiwan, Province of China",1967,22,1,101,0,0,1967-12-07,"R/22/2328B",0,0,"PRIVILEGES AND IMMUNITIES","TO ADOPT DRAFT RESOL. (A/6965) URGING U.N. MEMBER-STATES WHO HAVE NOT YET DONE SO TO ACCEDE TO THE U.N. CONVENTION ON (DIPLOMATIC) PRIVILEGES AND IMMUNITIES AND DEPLORING ALL DEPARTURES FROM THE RULES OF INTERNATIONAL LAW ON THE SUBJECT.",0,0,0,0,0,0,0,22028
1002,101,1,3,"VEN","Venezuela, Bolivarian Republic of",1967,22,11,50,51,0,1967-12-07,"R/22/2338A",1,1,"INTERNATIONAL YEAR FOR HUMAN RIGHTS","TO ADOPT THE AMENDMENT (A/L. 542) TO DRAFT RESOL. (A/7008) ON \INTERNATIONAL YEAR FOR HUMAN RIGHTS\\, WHICH AMENDMENT DELETES OPERATIVE PARAG.10.\""""",0,0,0,1,0,0,0,22029

Мне удалось предоставить вам небольшой файл, но в остальном я плохо разбираюсь в сортировке и совершенно не понимаю, что может быть причиной этого!

Изменить: Steeldriver очень помог, указав, что в этом файле есть кавычки. Если причина в кавычках, он должен где-то сравнивать строки! Почему это не противоречило параметру -n? Разве нельзя позволить ему найти строки, в которых строка 7 не содержит номера, и дать ему указание удалить предыдущую запятую?

0
задан 13 November 2020 в 11:00

0 ответов

Другие вопросы по тегам:

Похожие вопросы: