Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior using -I option #250

Closed
aborruso opened this issue Jun 2, 2019 · 6 comments
Closed

Strange behavior using -I option #250

aborruso opened this issue Jun 2, 2019 · 6 comments
Labels

Comments

@aborruso
Copy link
Contributor

aborruso commented Jun 2, 2019

Hi,
I have this input file

cod_amm,com,Regione,Denominazione in italiano,Codice Comune formato alfanumerico
c_a001,Abano Terme,Veneto,Abano Terme,
c_a004,Abbadia Cerreto,Lombardia,Abbadia Cerreto,098001
c_a005,Abbadia Lariana,Lombardia,Abbadia Lariana,097001

If I run

mlr --csv filter -S '${Codice Comune formato alfanumerico}!=""' \
then cut -f cod_amm,"Codice Comune formato alfanumerico" input.csv

I have a right result

cod_amm,Codice Comune formato alfanumerico
c_a004,098001
c_a005,097001

If I add -I at the beginning, I have in the input file only one field:

cod_amm
c_a004
c_a005

Is it a right behavior?

Thank you

@johnkerl johnkerl added the bug label Jun 3, 2019
@aborruso
Copy link
Contributor Author

aborruso commented Jun 9, 2019

I'm adding another strange behavior, related to -I.

I have this input file

Codice Comune formato alfanumerico,REGIONE,COMUNE_1
066001,ABRUZZO,ACCIANO
066002,ABRUZZO,AIELLI
066003,ABRUZZO,ALFEDENA

If I run

mlr --csv rename "Codice Comune formato alfanumerico",codiceComuneISTAT,REGIONE,nomeRegione,COMUNE_1,nomeComune input.csv

I have no error. If I had -I miller does not run properly and it stops itself.

@aborruso
Copy link
Contributor Author

I'm adding another one. Starting from

Stazioni,01:00,02:00,03:00,04:00,05:00,06:00,07:00,08:00,09:00,10:00,11:00,12:00,data,intervalloOrario,parametro
Corleone,16.7,16.7,17.2,16.7,17.7,19,21.2,24.5,28,30,31.7,32.9,2019-06-20,01-12,01
Acate,0.5,0.3,0.5,0.8,1.2,0.8,1.1,1.3,1.5,1.8,2.3,2.5,2019-06-20,01-12,05
Mazzarrone,3.6,4.2,3.1,3.6,2.3,1.9,2.4,3.7,4.3,4.1,5.4,6.6,2019-06-20,01-12,06
Novara di Sicilia,248,269,297,302,205,186,189,233,11,354,346,346,2019-06-20,01-12,07
Lascari,0,0,0,,,,,,,,,,2019-06-20,01-12,11
Bronte,0,,,,,,,,,,,,2019-06-20,01-12,11
Torregrotta,84,85,84,84,82,69,54,50,48,49,51,49,2019-06-20,01-12,04
Enna,3,29,349,5,355,79,8,228,185,168,25,248,2019-06-20,01-12,07
Novara di Sicilia,0.4,0.5,0.4,0.4,0.4,0.5,0.9,0.9,1,1,0.9,0.9,2019-06-20,01-12,05
Piazza Armerina,0.7,0.9,0.5,0.7,0.7,0.4,0.5,1.1,1.6,1.7,1.8,1.5,2019-06-20,01-12,05

and applying mlr -I --csv uniq -a then sort -f data,intervalloOrario,parametro,Stazioni input.csv the input file is not sorted.

Thank you

@johnkerl
Copy link
Owner

johnkerl commented Sep 2, 2019

Note: I have pushed commit 9e2cd33 but please do not use it. It is unreliable (in particular, does not address all of the above issues).

@johnkerl
Copy link
Owner

johnkerl commented Sep 2, 2019

Fixed in 1dee616. Thank you!! :)

@johnkerl johnkerl closed this as completed Sep 2, 2019
@johnkerl
Copy link
Owner

johnkerl commented Sep 2, 2019

$ cat gogo

# ================================================================
cat > input.csv.1 <<EOF
cod_amm,com,Regione,Denominazione in italiano,Codice Comune formato alfanumerico
c_a001,Abano Terme,Veneto,Abano Terme,
c_a004,Abbadia Cerreto,Lombardia,Abbadia Cerreto,098001
c_a005,Abbadia Lariana,Lombardia,Abbadia Lariana,097001
EOF

cp input.csv.1 input.csv

echo ----------------------------------------------------------------
mlr --opprint --icsv filter -S '${Codice Comune formato alfanumerico}!=""' then cut -f cod_amm,"Codice Comune formato alfanumerico" input.csv

echo ----------------------------------------------------------------
mlr -I --csv filter -S '${Codice Comune formato alfanumerico}!=""' then cut -f cod_amm,"Codice Comune formato alfanumerico" input.csv
mlr --icsv --opprint cat input.csv
echo ----------------------------------------------------------------


# ================================================================
cat > input.csv.2 <<EOF
Codice Comune formato alfanumerico,REGIONE,COMUNE_1
066001,ABRUZZO,ACCIANO
066002,ABRUZZO,AIELLI
066003,ABRUZZO,ALFEDENA
EOF

cp input.csv.2 input.csv

echo ----------------------------------------------------------------
mlr --opprint --icsv rename "Codice Comune formato alfanumerico",codiceComuneISTAT,REGIONE,nomeRegione,COMUNE_1,nomeComune input.csv

echo ----------------------------------------------------------------
mlr -I --csv rename "Codice Comune formato alfanumerico",codiceComuneISTAT,REGIONE,nomeRegione,COMUNE_1,nomeComune input.csv

mlr --icsv --opprint cat input.csv
echo ----------------------------------------------------------------


# ================================================================
cat > input.csv.3 <<EOF
Stazioni,01:00,02:00,03:00,04:00,05:00,06:00,07:00,08:00,09:00,10:00,11:00,12:00,data,intervalloOrario,parametro
Corleone,16.7,16.7,17.2,16.7,17.7,19,21.2,24.5,28,30,31.7,32.9,2019-06-20,01-12,01
Acate,0.5,0.3,0.5,0.8,1.2,0.8,1.1,1.3,1.5,1.8,2.3,2.5,2019-06-20,01-12,05
Mazzarrone,3.6,4.2,3.1,3.6,2.3,1.9,2.4,3.7,4.3,4.1,5.4,6.6,2019-06-20,01-12,06
Novara di Sicilia,248,269,297,302,205,186,189,233,11,354,346,346,2019-06-20,01-12,07
Lascari,0,0,0,,,,,,,,,,2019-06-20,01-12,11
Bronte,0,,,,,,,,,,,,2019-06-20,01-12,11
Torregrotta,84,85,84,84,82,69,54,50,48,49,51,49,2019-06-20,01-12,04
Enna,3,29,349,5,355,79,8,228,185,168,25,248,2019-06-20,01-12,07
Novara di Sicilia,0.4,0.5,0.4,0.4,0.4,0.5,0.9,0.9,1,1,0.9,0.9,2019-06-20,01-12,05
Piazza Armerina,0.7,0.9,0.5,0.7,0.7,0.4,0.5,1.1,1.6,1.7,1.8,1.5,2019-06-20,01-12,05
EOF

cp input.csv.3 input.csv

echo ----------------------------------------------------------------
mlr --opprint --icsv uniq -a then sort -f data,intervalloOrario,parametro,Stazioni input.csv

echo ----------------------------------------------------------------
mlr -I --csv uniq -a then sort -f data,intervalloOrario,parametro,Stazioni input.csv
mlr --icsv --opprint cat input.csv
echo ----------------------------------------------------------------
$ sh gogo
----------------------------------------------------------------
cod_amm Codice Comune formato alfanumerico
c_a004  098001
c_a005  097001
----------------------------------------------------------------
cod_amm Codice Comune formato alfanumerico
c_a004  098001
c_a005  097001
----------------------------------------------------------------
----------------------------------------------------------------
codiceComuneISTAT nomeRegione nomeComune
066001            ABRUZZO     ACCIANO
066002            ABRUZZO     AIELLI
066003            ABRUZZO     ALFEDENA
----------------------------------------------------------------
codiceComuneISTAT nomeRegione nomeComune
066001            ABRUZZO     ACCIANO
066002            ABRUZZO     AIELLI
066003            ABRUZZO     ALFEDENA
----------------------------------------------------------------
----------------------------------------------------------------
Stazioni          01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 12:00 data       intervalloOrario parametro
Corleone          16.7  16.7  17.2  16.7  17.7  19    21.2  24.5  28    30    31.7  32.9  2019-06-20 01-12            01
Torregrotta       84    85    84    84    82    69    54    50    48    49    51    49    2019-06-20 01-12            04
Acate             0.5   0.3   0.5   0.8   1.2   0.8   1.1   1.3   1.5   1.8   2.3   2.5   2019-06-20 01-12            05
Novara di Sicilia 0.4   0.5   0.4   0.4   0.4   0.5   0.9   0.9   1     1     0.9   0.9   2019-06-20 01-12            05
Piazza Armerina   0.7   0.9   0.5   0.7   0.7   0.4   0.5   1.1   1.6   1.7   1.8   1.5   2019-06-20 01-12            05
Mazzarrone        3.6   4.2   3.1   3.6   2.3   1.9   2.4   3.7   4.3   4.1   5.4   6.6   2019-06-20 01-12            06
Enna              3     29    349   5     355   79    8     228   185   168   25    248   2019-06-20 01-12            07
Novara di Sicilia 248   269   297   302   205   186   189   233   11    354   346   346   2019-06-20 01-12            07
Bronte            0     -     -     -     -     -     -     -     -     -     -     -     2019-06-20 01-12            11
Lascari           0     0     0     -     -     -     -     -     -     -     -     -     2019-06-20 01-12            11
----------------------------------------------------------------
Stazioni          01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 12:00 data       intervalloOrario parametro
Corleone          16.7  16.7  17.2  16.7  17.7  19    21.2  24.5  28    30    31.7  32.9  2019-06-20 01-12            01
Torregrotta       84    85    84    84    82    69    54    50    48    49    51    49    2019-06-20 01-12            04
Acate             0.5   0.3   0.5   0.8   1.2   0.8   1.1   1.3   1.5   1.8   2.3   2.5   2019-06-20 01-12            05
Novara di Sicilia 0.4   0.5   0.4   0.4   0.4   0.5   0.9   0.9   1     1     0.9   0.9   2019-06-20 01-12            05
Piazza Armerina   0.7   0.9   0.5   0.7   0.7   0.4   0.5   1.1   1.6   1.7   1.8   1.5   2019-06-20 01-12            05
Mazzarrone        3.6   4.2   3.1   3.6   2.3   1.9   2.4   3.7   4.3   4.1   5.4   6.6   2019-06-20 01-12            06
Enna              3     29    349   5     355   79    8     228   185   168   25    248   2019-06-20 01-12            07
Novara di Sicilia 248   269   297   302   205   186   189   233   11    354   346   346   2019-06-20 01-12            07
Bronte            0     -     -     -     -     -     -     -     -     -     -     -     2019-06-20 01-12            11
Lascari           0     0     0     -     -     -     -     -     -     -     -     -     2019-06-20 01-12            11
----------------------------------------------------------------

@aborruso
Copy link
Contributor Author

aborruso commented Sep 2, 2019

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants