Version 1.0
Copyright © 2022 Lowell D. Thomas
Python APG
 … an ABNF Parser Generator
Variables
examples.exp.csv Namespace Reference

Variables

string title
 
string csv_value
 
string csv_line
 
string input = '''Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K'''
 
string pat = 'PATTERN'
 
string header = 'RESULT'
 
int testno = 0
 
 exp = ApgExp(csv_value, 'g')
 
 result = exp.exec(input)
 
 strip = result.match[1:-1]
 
 match = utils.tuple_to_string(rule)
 

Variable Documentation

◆ csv_line

string examples.exp.csv.csv_line
Initial value:
1 = '''csv = field *(%d44 field)
2 field = quoted / text
3 quoted = %d34 quoted-text %d34
4 quoted-text = *(any-but-quote / double-quote)
5 double-quote = 2%d34
6 any-but-quote = %d32-33 / %d35-126
7 text = *any-but-comma
8 any-but-comma = %d32-43 / %d45-126
9 '''

Definition at line 38 of file csv.py.

◆ csv_value

string examples.exp.csv.csv_value
Initial value:
1 = '''value = begin-anchor field end-anchor
2 begin-anchor = &&%d44 / %^
3 end-anchor = &%d44 / %$
4 field = quoted / text
5 quoted = %d34 quoted-text %d34
6 quoted-text = *(any-but-quote / double-quote)
7 double-quote = 2%d34
8 any-but-quote = %d32-33 / %d35-126
9 text = *any-but-comma
10 any-but-comma = %d32-43 / %d45-126
11 '''

Definition at line 27 of file csv.py.

◆ exp

examples.exp.csv.exp = ApgExp(csv_value, 'g')

Definition at line 53 of file csv.py.

◆ header

string examples.exp.csv.header = 'RESULT'

Definition at line 49 of file csv.py.

◆ input

string examples.exp.csv.input = '''Ten Thousand,10000, 2710 ,,"10,000","It's ""10 Grand"", baby",10K'''

Definition at line 47 of file csv.py.

◆ match

examples.exp.csv.match = utils.tuple_to_string(rule)

Definition at line 83 of file csv.py.

◆ pat

string examples.exp.csv.pat = 'PATTERN'

Definition at line 48 of file csv.py.

◆ result

examples.exp.csv.result = exp.exec(input)

Definition at line 60 of file csv.py.

◆ strip

examples.exp.csv.strip = result.match[1:-1]

Definition at line 64 of file csv.py.

◆ testno

int examples.exp.csv.testno = 0

Definition at line 50 of file csv.py.

◆ title

string examples.exp.csv.title
Initial value:
1 = '''This example will demonstrate how to parse the
2 Microsoft format for comma separated values.
3 Two approaches are compared. One is to parse out one value
4 at a time with repeated searches using the global flag.
5 The other is to parse all values out of a line in one fell swoop.
6 Note that some translation is required to get the values
7 from quoted fields.
8 This problem is addressed in Jeffrey Friedl's book
9 "Mastering Regular Expressions", pg. 213
10 You can compare this solution to his discussion there.
11 '''

Definition at line 13 of file csv.py.

Python APG, Version 1.0, is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.