ickc / pantable

CSV Tables in Markdown: Pandoc Filter for CSV Tables
https://ickc.github.io/pantable/
BSD 3-Clause "New" or "Revised" License
86 stars 15 forks source link

Allowing caller to specify the csv dialect #36

Closed fralau closed 5 years ago

fralau commented 6 years ago

Thanks a lot for this good development of pantable. Currently, it supports the default format of csv (essentially commas as separator).

It would be good if it also allowed different csv formats (e.g. semicolons as separator).

I would like to define something according to those lines in pantable.py:

dialect = csv.excel
dialect.delimiter = ';'

def read_data(include, data, delimiter, dialect):
     ....
    raw_table_list = list(csv.reader(file, delimiter=delimiter, dialect=dialect))

As a suggestion, there could be two complementary approaches:

What would you think about this?

ickc commented 6 years ago

I had thought about this in the beginning, started a discussion on pandoc-discuss about filter options. Since none of the suggestions there has been materialized, probably we should just use env. var. to pass filter options.

ickc commented 6 years ago

c.f. #8

fralau commented 6 years ago

Indeed I had tested this and found that command-line arguments did not work; pity because it would make sense.

This is why I am suggesting, as a workaround, to do that change with environment variables (e.g. export PANTABLE_DELIMITER=';').

ickc commented 5 years ago

I just pushed v0.12.1 that has a csv-kwargs option. See the doc for (not so much) details. This is a case that no test is written. So I'd appreciate if you could add an example at the end of tests/test_pantable.md.