-
Notifications
You must be signed in to change notification settings - Fork 17
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
Output of parse-csv() #1018
Comments
Apart from being simpler, other benefits include: (a) it is possible to compare results using deep-equal (not possible before because of the function items) |
I like this. If I remember correctly, one incentive for the given structure was the perspective of converting CSV bidirectionally, with
Input with duplicate header names is quite common. I would suggest combining the data to the existing entry. Here’s approximate input that I was just confronted with. With the proposed solution, … "key,value,value,value,value
id2342,5,343,1,78
id1342,800"
=> csv:parse(map { 'format': 'xquery' }) …would result in… map { 'key': id2342, 'value': ('5', '343', '1', '78') },
map { 'key': id1342, 'value': ('800') We could also offer a
A plain sequence would make it even easier.
…I believe that we should offer a function that seems like a good default solution for most users. As the name of the other function Finally, we could this default for |
Closed in favour of #1052. |
I propose making some simplifications to the output of parse-csv() to make it more amenable to processing.
columns
record with a simple array of field names. It's easy enough to map names to positions using index-of.I also propose changing the name to
csv-to-maps
for consistency withcsv-to-table
andcsv-to-arrays
.We should advocate use of csv-to-arrays where data is to be accessed positionally, and csv-to-maps where it is to be accessed by column names, and optimise the design accordingly.
Looking at a use case, the first example (§15.4.7.1) would be unnecessary if as proposed we change csv-to-xml to generate XHTML directly, But if it were needed, it would change from
to
The text was updated successfully, but these errors were encountered: