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

Allowing caller to specify the csv dialect #36

Closed
fralau opened this issue Oct 1, 2018 · 4 comments
Closed

Allowing caller to specify the csv dialect #36

fralau opened this issue Oct 1, 2018 · 4 comments

Comments

@fralau
Copy link

fralau commented Oct 1, 2018

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:

  • command-line: allow the caller to specify dialect and delimiters from directly from bash, as environment variables, e.g. export PANTABLE_DELIMITER=';' ; export PANTABLE_DIALECT=excel (my preferred one, since "Excel with ;" is a very workable default)
  • as parameters: specify the delimiter and dialect in the yaml header of the markdown file.

What would you think about this?

@ickc
Copy link
Owner

ickc commented Oct 2, 2018

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
Copy link
Owner

ickc commented Oct 2, 2018

c.f. #8

@fralau
Copy link
Author

fralau commented Oct 3, 2018

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=';').

@fralau fralau changed the title Allowing to specify the csv dialect Allowing caller to specify the csv dialect Oct 4, 2018
@ickc
Copy link
Owner

ickc commented May 20, 2019

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.

@ickc ickc closed this as completed May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants