v3.1.1: Using the comma_separated_list with a pound sign #513
leewilmott
started this conversation in
General
Replies: 1 comment
-
I managed to find the answer to my own problem. I looked at the code and worked out how DelimitedList works (by looking at this). This allowed me to write the following code:
The above returns this: Hopefully this might help someone who has the same requirement as me. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I hope someone can help me. I'm using PyParsing v3.1.1.
I'm trying to separate a Comma Separated Values list and I'm having some difficulties.
This is what I'm trying to do:
I obviously start with this:
import pyparsing
...and then...
>>> test = "Item1, Item2, Item3, £10.99, Item 5, \"Item 6a, Item 6b\""
>>> pyparsing.common.comma_separated_list.parseString(test).asList()
The above returns the following:
['Item1', 'Item2', 'Item3', '']
...but I was expecting the result to be:
['Item1', 'Item2', 'Item3', '£10.99', 'Item 5', 'Item 6a, Item 6b']
If I remove the pound sign I receive different results.
>>> test = "Item1, Item2, Item3, 10.99, Item 5, \"Item 6a, Item 6b\""
>>> pyparsing.common.comma_separated_list.parseString(test).asList()
which returns this:
['Item1', 'Item2', 'Item3', '10.99', 'Item 5', '"Item 6a, Item 6b"']
...but I was expecting the result to be:
['Item1', 'Item2', 'Item3', '10.99', 'Item 5', 'Item 6a, Item 6b']
So, I have two problems:
Can anyone please help me?
Beta Was this translation helpful? Give feedback.
All reactions