Closed rajdevworks closed 2 months ago
Hi!
You're missing a quotation mark after .csv. And you have an extra quotation at the end.
Try
{{ read_csv('docs/assets/csv/error_codes.csv', usecols=["X", "EE"]) }}
Thanks @timvink . After fixing the missing quotation mark, here is what I have
{{ read_csv('docs/assets/file.csv', usecols = ["A", "B"]) }}
Error I get during mkdocs serve
File "/opt/homebrew/lib/python3.11/site-packages/mkdocs/plugins.py", line 507, in run_event result = method(item, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/mkdocs_table_reader_plugin/plugin.py", line 94, in on_page_markdown pd_args, pd_kwargs = parse_argkwarg(result[1]) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/mkdocs_table_reader_plugin/safe_eval.py", line 83, in parse_argkwarg raise AssertionError( AssertionError: [table-reader-plugin] Make sure the python in your reader tag is correct: Positional arguments follow keyword arguments in ''docs/assets/file.csv', usecols = ["A", "B"]'
Check that it works in python. Try not to mix the quotation mark types (single or double)
I did a test and the quotation mark type did work
$ python3 py-test.py
A B 0 10 23 1 34 56 2 93 67
$ cat py-test.py
import pandas as pd # Read the CSV file into a pandas DataFrame #df = pd.read_csv('file.csv') df = pd.read_csv('file.csv', usecols=["A", "B"]) # Print the first few rows of the DataFrame print(df.head())
$ cat file.csv
A,B,C,D,E 10,23,45,78,99 34,56,87,12,37 93,67,34,23,11%
Thanks for the example. This is actually a bug I can reproduce. It was a bug in the way I parsed args and kwargs from the string; you were passing a list with an additional ,
.
Fixing now..
Will make a new release now
Hello, so I have 10 columns in my csv file and want to read only columns 3 to 7. Using pandas read_csv, I can pass parameter
usecols
which allows to pick columns to read from a given csv.How can I do the same with this reader plugin
read_csv
? Here is what I have and it is failing. I'm using mkdocs material theme.