
As commented, Bernard's solution is the simplest and therefore the best to use the counter, IMHO. Said that, another possibility is not set any counter nor any complex preamble.
If you don't know R and knitr, this solution is a bit like killing flies with cannon shots (although I strongly suggest you to know knitr if you often deal with numeric data and/or graphs in LaTeX documents). If you know how compile the test.Rnw below, is very simple, as any data frame output show by default row numbers, so you don't have to do anything special, just have some data frame (it can be imported from several formats as CSV or Excel or just typed in R code as showed in the example) and print it like a LaTeX table with xtable (or kable, or some others R packages):
% test.Rnw
\documentclass{article}
\usepackage{booktabs} % for better rules
\begin{document}
<<table1, echo=F,results='asis'>>=
library(xtable)
# the data
df <- data.frame(
value=c(4.53, 6.74,7.1),
price=c(23,45,15))
# the table
xtable(df)
@
With a header for the counter
(rather superfluous, but ...)
and some table format:
<<table2,echo=F,results='asis'>>=
df$number <- rownames(df) # numbers as variable
df <- df[,c(3,1,2)] # numbers as first column
print(xtable(df,align="lccc",digits=c(0,0,2,0)),
include.rownames=F,booktabs=T)
@
\end{document}
arraypackage and use{|>{\Rownum}l|l|}as the table preamble. Of course for the first row, you'd have to use\multicolumn{1}{|l}{number}. – Bernard Jan 18 '22 at 11:02{|l|}to no lost the awful vertical lines, but Bernard comment is the simplest (best) general answer. – Fran Jan 18 '22 at 11:35