Loading CSV Data
Our goal is to build a listener that loads comma-separated-value (CSV) data into a nice âlist of mapsâ data structure. This is the kind of thing that any data format reader or even a configuration file reader would do. Weâll collect the fields of each row into a map that associates a header name with a value. So, given the following input:
â | Details,Month,Amount |
â | Mid Bonus,June,"$2,000" |
â | ,January,"""zippo""" |
â | Total Bonuses,"","$5,000" |
weâd like to see the following list of maps printed out:
â | [{Details=Mid Bonus, Month=June, Amount="$2,000"}, |
â | {Details=, Month=January, Amount="""zippo"""}, |
â | {Details=Total Bonuses, Month="", Amount="$5,000"}] |
To get precise methods within our listener, ...
Get The Definitive ANTLR 4 Reference, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.