[ANN] TableIO - simple reading and writing of tabular data (experimental)

Nice time saver. Is there a way to extend support for XML file strukture?

The issue with xml is that there is no unique standard way how to represent a tabular structure. For automatic parsing, a specific structure of the xmls would need to be assumed, e.g. attributes top-level = row indices, attributes level 2 = column names and level 2 content = field value. Such a parser would, however, be not very useful because many xmls have a different scheme.
For JSON, in contrast, it is easier because there are essentially only 2 ways to represent tabular data: list of dicts and dict of lists.
In principle, it should be possible to write an xml parser which supports different schemes by providing information about content root, etc. as parameters, like here: https://pypi.org/project/pandas-read-xml/
This would be, however, a much larger project (but surely very useful).

I think this is better

read_table([callable], filename, [table_name])

The callable can be a function in which case fn(table) is what is read. And also you can put thing like DataFrame there and have a special dispatch for it. Like

read_table(DataFrame, "path/to/file") then ti will return a DataFrame, you can have it such that

read_table(callable, path) = callable(_read_table(path))


read_table(::type{DataFrame}, path) = ... something customised code to make dataframe faster

1 Like