|
|
От: |
SmaLL75
|
http://smallweb.narod.ru |
| Дата: | 28.09.17 07:00 | ||
| Оценка: | |||
for event, elem in ET.iterparse(xml, events=('start', 'end')):
if event is "start":
....| пример xml | |
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <pivotCacheRecords xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" count="236834"> <r> <s v="3632025024"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <n v="1"/> <x v="0"/> <x v="0"/> <x v="0"/> <s v="177230"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <d v="2014-10-17T00:00:00"/> <n v="1051"/> <x v="0"/> <x v="0"/> </r> <r> <s v="3632369876"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="1"/> <x v="1"/> <x v="1"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <x v="0"/> <n v="1"/> <x v="0"/> <x v="1"/> <x v="0"/> <s v="214239"/> <x v="0"/> <x v="1"/> <x v="0"/> <x v="1"/> <x v="1"/> <x v="0"/> <x v="0"/> <x v="0"/> <d v="2016-07-22T00:00:00"/> <n v="407"/> <x v="1"/> <x v="0"/> </r> | |
|
|
От: |
Senyai
|
http://www.arseniy.net |
| Дата: | 28.09.17 10:21 | ||
| Оценка: | |||
SLL>for event, elem in ET.iterparse(xml, events=('start', 'end')):
SLL> if event is "start":
SLL>....
SLL>|
|
От: |
SmaLL75
|
http://smallweb.narod.ru |
| Дата: | 28.09.17 11:01 | ||
| Оценка: | |||
SLL>>for event, elem in ET.iterparse(xml, events=('start', 'end')):
SLL>> if event is "start":
SLL>>....
SLL>>|
|
От: |
Senyai
|
http://www.arseniy.net |
| Дата: | 28.09.17 11:12 | ||
| Оценка: | |||
|
|
От: |
SmaLL75
|
http://smallweb.narod.ru |
| Дата: | 28.09.17 11:37 | ||
| Оценка: | |||
for event, elem in ET.iterparse(xml, events=('start', 'end')):
record = {}
if event == "start":
if elem.tag == "{http://schemas.openxmlformats.org/spreadsheetml/2006/main}r":
for rnum, item in enumerate(elem):
if len(elem) != 33 and rnum ==0:
print(item.attrib['v'])
record.update({rnum: item.attrib['v']})
rec = list(record.values())
record.clear()
f.write(";".join(rec) + "\n")
elem.clear()
|
|
От: |
Senyai
|
http://www.arseniy.net |
| Дата: | 28.09.17 12:05 | ||
| Оценка: | |||
SLL>for event, elem in ET.iterparse(xml, events=('start', 'end')):
SLL> record = {}
SLL> if event == "start":
SLL> if elem.tag == "{http://schemas.openxmlformats.org/spreadsheetml/2006/main}r":
SLL> for rnum, item in enumerate(elem):
SLL> if len(elem) != 33 and rnum ==0:
SLL> print(item.attrib['v'])
SLL> record.update({rnum: item.attrib['v']})
SLL> rec = list(record.values())
SLL> record.clear()
SLL> f.write(";".join(rec) + "\n")
SLL> elem.clear()
SLL>3632025024;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;177230;0;0;0;0;0;0;0;0;2014-10-17T00:00:00;1051;0;0\n'
3632369876;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;1;0;1;0;214239;0;1;0;1;1;0;0;0;2016-07-22T00:00:00;407;1;0\n'|
|
От: |
SmaLL75
|
http://smallweb.narod.ru |
| Дата: | 28.09.17 13:42 | ||
| Оценка: | |||
SLL>>for event, elem in ET.iterparse(xml, events=('start', 'end')):
SLL>> record = {}
SLL>> if event == "start":
SLL>> if elem.tag == "{http://schemas.openxmlformats.org/spreadsheetml/2006/main}r":
SLL>> for rnum, item in enumerate(elem):
SLL>> if len(elem) != 33 and rnum ==0:
SLL>> print(item.attrib['v'])
SLL>> record.update({rnum: item.attrib['v']})
SLL>> rec = list(record.values())
SLL>> record.clear()
SLL>> f.write(";".join(rec) + "\n")
SLL>> elem.clear()
SLL>>S>3632025024;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;177230;0;0;0;0;0;0;0;0;2014-10-17T00:00:00;1051;0;0\n'
S>3632369876;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;1;0;1;0;214239;0;1;0;1;1;0;0;0;2016-07-22T00:00:00;407;1;0\n'
S>|
|
От: |
Senyai
|
http://www.arseniy.net |
| Дата: | 28.09.17 14:06 | ||
| Оценка: | |||
S>>3632025024;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;177230;0;0;0;0;0;0;0;0;2014-10-17T00:00:00;1051;0;0\n'
S>>3632369876;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;1;0;1;0;214239;0;1;0;1;1;0;0;0;2016-07-22T00:00:00;407;1;0\n'
S>>Note
iterparse() only guarantees that it has seen the “>” character of a starting tag when it emits a “start” event, so the attributes are defined, but the contents of the text and tail attributes are undefined at that point. The same applies to the element children; they may or may not be present.
If you need a fully populated element, look for “end” events instead.
|
|
От: |
SmaLL75
|
http://smallweb.narod.ru |
| Дата: | 03.10.17 06:45 | ||
| Оценка: | |||
S>>>3632025024;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;1;0;0;0;177230;0;0;0;0;0;0;0;0;2014-10-17T00:00:00;1051;0;0\n'
S>>>3632369876;0;0;0;0;0;1;1;1;0;0;0;0;0;0;0;1;0;1;0;214239;0;1;0;1;1;0;0;0;2016-07-22T00:00:00;407;1;0\n'
S>>>S>Note
S>iterparse() only guarantees that it has seen the “>” character of a starting tag when it emits a “start” event, so the attributes are defined, but the contents of the text and tail attributes are undefined at that point. The same applies to the element children; they may or may not be present.
S>If you need a fully populated element, look for “end” events instead.