TransWikia.com

pgfplotstable - siunitx error with data from csv with values in scientific notation

TeX - LaTeX Asked by fist on July 15, 2021

I want to create table using pgfplotstable with data from csv file with values in scientific notation, but when i try to compile the file to pdf I end up with following siunitx errors

Package siunitx: Invalid numerical input '8.47e'.
Package siunitx: Invalid numerical input '2e'.
Package siunitx: Invalid numerical input '1.9e'.
Package siunitx: Invalid numerical input '2e'.
and so on...

Here is my code

    begin{table}[h!]
        begin{center}
            pgfplotstabletypeset[
                col sep=comma,
                header=false,
                display columns/0/.style={
                    column name=$U_{led}$,
                    column type={S},
                    string type
                },
                display columns/1/.style={
                    column name=$I_{led}$,
                    column type={S},
                    string type
                },
                display columns/2/.style={
                    column name=$U_{det}$,
                    column type={S},
                    string type
                },
                every head row/.style={
                    before row={toprule},
                    after row={{[si{volt}]} & {[si{milliampere}]} & {[si{volt}]}midrule}
                },
                every last row/.style={after row=bottomrule},
            ]{../data/va_lux_char.csv}
            label{table:va_lux}
            caption{Tabulka}
        end{center}
    end{table}

and here is my CSV file

0.646,8.47e-08,2e-06
1.11,1.9e-07,2e-06
1.288,2.96e-07,2e-06
1.388,6.97e-07,2e-06
1.413,9.93e-07,2e-06
1.456,1.99e-06,2e-06
1.479,3e-06,2e-06
1.526,6.99e-06,2e-06
1.545,9.99e-06,2e-06
1.581,2e-05,0.000124
1.602,3e-05,0.000384
1.644,7e-05,0.00231
1.698,0.0002,0.0141
1.718,0.0003,0.0249
1.765,0.0007,0.0639
1.788,0.001,0.0858
1.838,0.002,0.131
1.875,0.003,0.159
1.978,0.007,0.218
2.037,0.01,0.242
2.205,0.02,0.288
2.35,0.03,0.315
2.443,0.037,0.329

EDIT:
I found out the problem was in combination of siunitx and czech babel packege which uses - as active character, so usign shorthandoff{-} above and shorthandon{-} below the table solved the problem and now it works fine.

One Answer

enter image description here

 documentclass[10pt,a4paper]{article}

usepackage{graphicx, pgfplots,array,booktabs,siunitx,}
usepackage{pgfplotstable,filecontents}

begin{filecontents}{data1.csv}
    0.646,8.47e-08,2e-06
    1.11,1.9e-07,2e-06
    1.288,2.96e-07,2e-06
    1.388,6.97e-07,2e-06
    1.413,9.93e-07,2e-06
    1.456,1.99e-06,2e-06
    1.479,3e-06,2e-06
    1.526,6.99e-06,2e-06
    1.545,9.99e-06,2e-06
    1.581,2e-05,0.000124
    1.602,3e-05,0.000384
    1.644,7e-05,0.00231
    1.698,0.0002,0.0141
    1.718,0.0003,0.0249
    1.765,0.0007,0.0639
    1.788,0.001,0.0858
    1.838,0.002,0.131
    1.875,0.003,0.159
    1.978,0.007,0.218
    2.037,0.01,0.242
    2.205,0.02,0.288
    2.35,0.03,0.315
    2.443,0.037,0.329
end{filecontents}

begin{document}
     begin{table}[h!]
        begin{center}
            pgfplotstabletypeset[
            col sep=comma,
            header=false,
            display columns/0/.style={
                column name=$U_{led}$,
                column type={S},
                string type
            },
            display columns/1/.style={
                column name=$I_{led}$,
                column type={S},
                string type
            },
            display columns/2/.style={
                column name=$U_{det}$,
                column type={S},
                string type
            },
            every head row/.style={
                before row={toprule},
                after row={{[si{volt}]} & {[si{milliampere}]} & {[si{volt}]}midrule}
            },
            every last row/.style={after row=bottomrule},
            ]{data1.csv}
            label{table:va_lux}
            caption{Tabulka}
        end{center}
    end{table}
end{document}

Answered by js bibra on July 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP