Created
January 30, 2017 19:38
-
-
Save jtemporal/8c4d48fc3a1df6643f01ca935dbd3d32 to your computer and use it in GitHub Desktop.
change in iterparse with ipdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [8]: convert_xml_to_csv('data/AnoAnterior.xml', 'data/AnoAnterior.csv') | |
2017-01-30 18:16:40 Creating the CSV file | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(67)convert_xml_to_csv() | |
66 import ipdb; ipdb.set_trace() | |
---> 67 create_csv(csv_file_path, headers) | |
68 | |
ipdb> n | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(69)convert_xml_to_csv() | |
68 | |
---> 69 count = 1 | |
70 output('Reading the XML file') | |
ipdb> n | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(70)convert_xml_to_csv() | |
69 count = 1 | |
---> 70 output('Reading the XML file') | |
71 for json_io in xml_parser(xml_file_path): | |
ipdb> n | |
2017-01-30 18:16:46 Reading the XML file | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(71)convert_xml_to_csv() | |
70 output('Reading the XML file') | |
---> 71 for json_io in xml_parser(xml_file_path): | |
72 csv_io = StringIO() | |
ipdb> s | |
--Call-- | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(18)xml_parser() | |
17 | |
---> 18 def xml_parser(xml_path, tag='DESPESA'): | |
19 """ | |
ipdb> n | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(23)xml_parser() | |
22 """ | |
---> 23 for _, node in iterparse(open(xml_path, encoding='utf-16'), tag=tag): | |
24 | |
ipdb> n | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(26)xml_parser() | |
25 # get data | |
---> 26 fields = {c.tag.lower(): c.text for c in node.iter() if c.tag != tag} | |
27 node.clear() | |
ipdb> n | |
> /root/anaconda3/envs/serenata_rosie/lib/python3.6/site-packages/serenata_toolbox/xml2csv.py(27)xml_parser() | |
26 fields = {c.tag.lower(): c.text for c in node.iter() if c.tag != tag} | |
---> 27 node.clear() | |
28 | |
ipdb> fields | |
*** UnicodeEncodeError: 'ascii' codec can't encode characters in position 224-225: ordinal not in range(128) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment