{"id":400629,"date":"2024-06-29T15:22:45","date_gmt":"2024-06-29T15:22:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=400629"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=400629","title":{"rendered":"<span>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0441 Python, xml, csv, sqlite. \u0427\u0430\u0441\u0442\u044c 2. \u0418\u0449\u0435\u043c \u0438 \u043f\u0440\u0430\u0432\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0438, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u043b\u0435\u0442\u0430\u0435\u043c \u043d\u0430\u2026<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/f60\/b48\/f34\/f60b48f34a64ffb3c89087a58ee01f2f.jpg\" width=\"2000\" height=\"1377\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f60\/b48\/f34\/f60b48f34a64ffb3c89087a58ee01f2f.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p><strong><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em><\/strong><em>\u00a0\u041a\u0430\u043a\u00a0\u0438\u00a0<\/em><a href=\"https:\/\/habr.com\/ru\/post\/577148\/\" rel=\"noopener noreferrer nofollow\"><em>\u043f\u0435\u0440\u0432\u0430\u044f\u00a0\u0447\u0430\u0441\u0442\u044c<\/em><\/a><em>\u00a0\u044d\u0442\u0430\u00a0\u0442\u043e\u0436\u0435\u00a0\u0434\u043b\u044f\u00a0\u0441\u043e\u0432\u0441\u0435\u043c\u00a0\u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445\u00a0\u043a\u043e\u0434\u0435\u0440\u043e\u0432-\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u0435\u0439\u00a0\u043d\u0430\u00a0\u041f\u0438\u0442\u043e\u043d\u0435.\u00a0\u0414\u043b\u044f\u00a0\u043f\u0440\u043e\u0436\u0436\u0435\u043d\u043d\u044b\u0445\u00a0\u043a\u043e\u0434\u0435\u0440\u043e\u0432\u00a0\u0431\u0443\u0434\u0435\u0442\u00a0\u0441\u043a\u0443\u0447\u043d\u043e.\u00a0<\/em>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u00a0\u0445\u043e\u0442\u0435\u043b\u0438\u00a0\u0432\u043d\u0435\u0441\u0442\u0438\u00a0\u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u00a0\u0441\u0440\u0430\u0437\u0443 \u0432\u00a0\u043f\u0435\u0440\u0432\u0443\u044e\u00a0\u0441\u0442\u0430\u0442\u044c\u044e\u00a0\u043f\u043e\u00a0\u043c\u0435\u0440\u0435\u00a0\u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u00a0\u043e\u0448\u0438\u0431\u043e\u043a, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0443\u043c\u0438\u044f \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e. \u041e\u0448\u0438\u0431\u043a\u0438 \u0438\u0441\u0447\u0435\u0437\u043d\u0443\u0442 \u0441\u043e\u0432\u0441\u0435\u043c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438\u043d\u043e\u0441\u044f\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u0443 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0435\u0440\u0430. \u0410 \u043f\u043e\u0441\u0435\u043c\u0443 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0430 \u0432 \u044d\u0442\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0442 \u043d\u0438\u0445 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/588066\/\" rel=\"noopener noreferrer nofollow\">\u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0442\u0440\u0438\u043b\u043e\u0433\u0438\u0438 \u0442\u0443\u0442 (\u0447\u0430\u0441\u0442\u044c 3): &#171;\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e-\u043f\u0438\u0442\u043e\u043d\u0438\u0439 \u0431\u043e\u0439 \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 sqlite \u0437\u0430 2 174 433 \u0441\u0442\u0440\u043e\u0447\u043a\u0438. \u0427\u0430\u0441\u0442\u044c 3&#187;<\/a><\/p>\n<h2>\u041d\u0430\u0447\u0430\u043b\u043e<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430\u00a0\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c\u00a0\u0432\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435\u00a0\u043d\u043e\u0432\u0443\u044e\u00a0\u043f\u0430\u043f\u043a\u0443,\u00a0\u043a\u0443\u0434\u0430\u00a0\u0431\u0443\u0434\u0435\u043c\u00a0\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c\u00a0\u0432\u0435\u0441\u044c\u00a0\u043a\u043e\u0434\u00a0\u0438\u0437\u00a0\u044d\u0442\u043e\u0439\u00a0\u0441\u0442\u0430\u0442\u044c\u0438.\u00a0\u0417\u0430\u0445\u043e\u0434\u0438\u043c\u00a0\u0432\u00a0\u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e\u00a0\u0441\u0442\u0440\u043e\u043a\u0443\u00a0\u0432\u0438\u043d\u0434\u043e\u0432\u0441\u00a0\u043f\u043e\u0434\u00a0\u0430\u0434\u043c\u0438\u043d\u043e\u043c:<\/p>\n<p><code>D:\\2021_8_16_oborot>mkdir\u00a0part2<\/code><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435\u00a0\u0438\u0434\u0435\u043c\u00a0\u043f\u043e\u00a0\u043f\u043e\u0440\u044f\u0434\u043a\u0443.\u00a0\u041c\u044b\u00a0\u0445\u043e\u0442\u0435\u043b\u0438\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u00a0\u043b\u0438\u00a0<code>\u0412\u0421\u0415<\/code>\u00a0\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435\u00a0xml-\u0444\u0430\u0439\u043b\u044b\u00a0\u0441\u0432\u043e\u0435\u043c\u0443\u00a0xsd\u00a0\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e.\u00a0<\/p>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 xml \u0444\u0430\u0439\u043b\u044b<\/h2>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c? \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 xml-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 (&#8230;\/ish_unziped) \u0441 xsd \u0441\u0445\u0435\u043c\u043e\u0439. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0433\u0443\u0434 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u043c\u044f \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u0438\u043d\u0430\u0447\u0435 \u043a \u043f\u043b\u043e\u0445\u0438\u043c.<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\14.09.2021_check_all_xml_files_in_dir.py  import lxml from lxml import etree import os import xml.etree.ElementTree as Xet  def s_errors():     path = 'D:\/2021_8_16_oborot\/ish_unziped\/'     filelist = os.listdir(path)     enu = 0     mis = 0     with open('D:\/2021_8_16_oborot\/part2\/xml_not_valid_errors_2.txt', 'a+', encoding='utf-8') as ef:         with open('D:\/2021_8_16_oborot\/part2\/xml_is_valid_2.txt', 'a+', encoding='utf-8') as va_f:             for t in filelist:                 enu = enu + 1                          with open('D:\/2021_8_16_oborot\/ish_unziped\/' + t, 'r', encoding='utf-8') as ft:                     xml_file = lxml.etree.parse(ft)                     xml_validator = lxml.etree.XMLSchema(file='D:\/2021_8_16_oborot\/structure-20180110.xsd')                     is_valid = xml_validator.validate(xml_file)                                      if is_valid == True:                         enu1 = str(enu)                         va_f.write(enu1)                         va_f.write(':::')                         va_f.write(t)                         va_f.write('|')                         va_f.write('file_matches_xsd')                         va_f.write('\\n')                                               else:                         enu1 = str(enu)                         mis = mis + 1                         mis_str = str(mis)                         ef.write(enu1)                         ef.write(':::')                         ef.write(t)                         ef.write('the_file_does_not_match_the_xsd_schema')                         ef.write('\\n')                          if __name__ == '__main__':     s_errors()<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:\u00a0&#171;\u043f\u043b\u043e\u0445\u043e\u0439&#187;\u00a0\u0444\u0430\u0439\u043b\u00a0\u043f\u0443\u0441\u0442\u043e\u0439,\u00a0\u0432\u00a0\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u00a0\u0432\u0441\u0435\u00a012060 +1\u00a0\u0444\u0430\u0439\u043b (\u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u043c\u044b \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0438!!!),\u00a0\u0438\u0442\u043e\u0433\u043e\u00a012061\u00a0\u0433\u0443\u0434\u00a0\u0444\u0430\u0439\u043b.\u00a0<\/p>\n<p>\u0412\u0438\u0434\u00a0\u0437\u0430\u043f\u0438\u0441\u0435\u0439\u00a0\u0442\u0430\u043a\u043e\u0439 (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 5 \u0441\u0442\u0440\u043e\u0447\u0435\u043a)<\/p>\n<pre><code class=\"python\">12057:::VO_OTKRDAN5_9965_9965_20210729_ffdf4a61-dc58-451e-8c76-46d63b534694.xml|file_matches_xsd 12058:::VO_OTKRDAN5_9965_9965_20210729_ffe07802-f596-46a2-aff3-24293c5162c0.xml|file_matches_xsd 12059:::VO_OTKRDAN5_9965_9965_20210729_ffe103cb-571e-4c05-9395-6d97814e6100.xml|file_matches_xsd 12060:::VO_OTKRDAN5_9965_9965_20210729_ffe3f7a0-c0db-4c6a-a231-98a429c51314.xml|file_matches_xsd 12061:::VO_OTKRDAN5_9965_9965_20210729_ffec8ca1-4e5d-42ea-ad3e-2ac45146da0d.xml|file_matches_xsd<\/code><\/pre>\n<p><strong><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/em><\/strong><em>. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0437\u0436\u0435 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f &#171;\u0431\u0438\u0442\u044b\u0445&#187; \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u0440\u0442\u0438\u0442\u044c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 \u0432 csv \u0438 \u0434\u0430\u043b\u0435\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 sqlite.<\/em><\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442 xml \u0432 csv \u0438 \u0434\u0430\u043b\u0435\u0435 \u0432 sqlite \u043d\u0430 \u041f\u0438\u0442\u043e\u043d\u0435<\/h2>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0442\u043e\u0440\u043e\u043f\u0438\u043b\u0438\u0441\u044c \u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0432\u044b\u044f\u0441\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u043c\u044b \u0442\u0430\u043c \u043d\u0435 \u0442\u043e \u043d\u0430\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0438\u043b\u0438 \u0432 \u041f\u0438\u0442\u043e\u043d\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 csv \u0432 sqlite, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e  &#8216;\u043f\u0435\u0440\u0435\u043f\u0440\u044b\u0433\u043d\u0443\u043b\u0438&#8217; \u0434\u0430\u043b\u044c\u0448\u0435 \u043a \u0444\u0438\u043d\u0438\u0448\u0443. \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f. \u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0\u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0430\u0439\u043f-pipe (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0424\u0438\u0433\u0443\u0440\u043d\u043e\u0432 \u043f\u0435\u0440\u0435\u0432\u0435\u043b, \u043a\u0430\u043a &#8216;\u0441\u0438\u043c\u0432\u043e\u043b \u0432\u043e\u0434\u043e\u043f\u0440\u043e\u0432\u043e\u0434\u0430&#8217;): <code>\"|\".<\/code> \u041f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 (\u043a\u0430\u043a \u043f\u043e\u0437\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0437\u0440\u044f), \u0447\u0442\u043e \u0432\u0440\u044f\u0434-\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f &#171;\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438 &#8216;\u043d\u0438\u043a\u043e\u0433\u0434\u0430&#8217;. \u041f\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043b\u0435\u043d\u044c \u0432 \u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445.\u00a0\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u0437\u0430\u043f\u044f\u0442\u0443\u044e <code>(\",\")<\/code>? \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438, \u043d\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u042e\u041b \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u044f\u0442\u044b\u0445 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e. \u0418 \u043f\u0440\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0435 \u0432 sqlite \u044d\u0442\u0438 \u0437\u0430\u043f\u044f\u0442\u044b\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u0436\u0435 \u043a\u0430\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0438 \u043b\u043e\u043c\u0430\u043b\u0438 \u0432\u0435\u0441\u044c \u0438\u043c\u043f\u043e\u0440\u0442. \u041f\u043e\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0439\u043f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f. \u0421\u0430\u043c\u0430 \u0441\u0445\u0435\u043c\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0441\u0442\u0430\u0440\u043e\u0439, \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c xml \u0432 csv, \u0430 \u043f\u043e\u0442\u043e\u043c csv \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 sqlite. \u0422\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0434\u0440\u0443\u0433\u043e\u0439. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u043d\u0430 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a &#8212; \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0438 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 xml \u0432 csv<\/h2>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 xml \u0432 csv. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438.<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\20.10.2021_mini_test_one_file_xml_to_csv_with_new_delimiter.py  import xml.etree.ElementTree as Xet  f = open('18_your_csv_file.csv', 'w', encoding='utf-8')  xmlparse = Xet.parse('D:\/2021_8_16_oborot\/ish_unziped\/test1.xml') root = xmlparse.getroot()   for i in root:     for i2 in i.findall('\u0421\u0432\u0435\u0434\u041d\u041f'):         f.writelines(i2.attrib['\u041d\u0430\u0438\u043c\u041e\u0440\u0433'])         f.write('|')         f.writelines(i2.attrib['\u0418\u041d\u041d\u042e\u041b'])         f.write('|')         #f.write('\\n')         for i2 in i.findall('\u0421\u0432\u0435\u0434\u0414\u043e\u0445\u0420\u0430\u0441\u0445'):             f.writelines(i2.attrib['\u0421\u0443\u043c\u0414\u043e\u0445\u043e\u0434'])             f.write('|')             f.writelines(i2.attrib['\u0421\u0443\u043c\u0420\u0430\u0441\u0445\u043e\u0434'])             f.write('\\n')                   f.close()<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u00a0\u043d\u043e\u0440\u043c,\u00a0\u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code>\u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e  \"\u0424\u0418\u0411\u0420\u041e\u0422\u0415\u041a\"|7816394401|0.00|0.00 \u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e \"\u0418\u0417\u0414\u0410\u0422\u0415\u041b\u042c\u0421\u041a\u0418\u0419 \u0414\u041e\u041c \"\u0422\u0412\u0415\u0420\u0421\u041a\u0410\u042f \u0416\u0418\u0417\u041d\u042c\"|6901026686|0.00|0.00 \u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e \"\u041c\u0420\u0410\u0412\"|7726503712|20800000.00|14102000.00 \u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e \"\u0410\u0413\u0420\u041e\u0420\u0415\u0421\u0423\u0420\u0421\"|6901026703|470000.00|461000.00<\/code><\/pre>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442 csv \u0432 table sqlite<\/h2>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0442\u0435\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u043e\u0434\u043d\u043e\u0433\u043e (\u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e) csv \u0444\u0430\u0439\u043b\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 sqlite. \u00a0<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\25.10.2021_mini_test_csv_to_sqlite_with_new_delimiter.py  import sqlite3 import csv import os  def create_db_table():     conn = sqlite3.connect('D:\/2021_8_16_oborot\/UL11.db')     c = conn.cursor()      # Create table     c.execute('''CREATE TABLE IF NOT EXISTS oborot_2019_fns12               (name_UL text, inn_UL int, oborot_2019 real, rashod_2019 real)''')  # ??? real==>>int???                 #commit the changes to db     conn.commit()     #close the connection     conn.close()  def import_one_file_csv_to_sqlite():      con = sqlite3.connect('D:\/2021_8_16_oborot\/UL11.db')     cur = con.cursor()      with open('D:\/2021_8_16_oborot\/part2\/19_your_csv_file.csv', 'r', encoding='utf-8') as f_open_csv:         rows = csv.reader(f_open_csv, delimiter=\"|\")                  for row in rows:             cur.execute('INSERT INTO oborot_2019_fns12 VALUES (?, ?, ?, ?)', row)      con.commit()     con.close()                      if __name__ == '__main__':     create_db_table()     import_one_file_csv_to_sqlite()<\/code><\/pre>\n<p>\u0412\u0441\u0435\u00a0\u0433\u0443\u0434,\u00a0\u0434\u0430\u043d\u043d\u044b\u0435\u00a0\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f\u00a0\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e.\u00a0\u0414\u0430\u043d\u043d\u044b\u0435\u00a0\u0432\u00a0\u0441\u0432\u043e\u0438\u0445\u00a0\u043f\u043e\u043b\u044f\u0445,\u00a0\u043d\u0435\u00a0\u043b\u0435\u0437\u0443\u0442\u00a0\u0432\u00a0\u0447\u0443\u0436\u0438\u0435.<\/p>\n<h2>\u0418\u043c\u043f\u043e\u0440\u0442 \u0432\u0441\u0435\u0445 xml \u0432 csv2 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c\u00a0\u0434\u0435\u043b\u0430\u0435\u043c\u00a0\u0442\u043e\u0436\u0435\u00a0\u0441\u0430\u043c\u043e\u0435,\u00a0\u043d\u043e\u00a0\u0447\u0438\u0442\u0430\u0435\u043c\u00a0\u0432\u0441\u0435\u00a0\u0444\u0430\u0439\u043b\u044b\u00a0\u0438\u0437\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0xml (&#8230;\/ish_unziped)\u00a0\u0432\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0csv.\u00a0\u0427\u0442\u043e\u0431\u044b\u00a0\u043d\u0435\u00a0\u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f\u00a0\u0441\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0435\u0439\u00a0\u0438\u0437\u00a0\u043f\u0435\u0440\u0432\u043e\u0439\u00a0\u0447\u0430\u0441\u0442\u0438\u00a0 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0\u043f\u043e\u0434\u00a0csv\u00a0\u0444\u0430\u0439\u043b\u044b\u00a0\u0438\u0437\u00a0\u0442\u0435\u043a\u0443\u0449\u0435\u0439\u00a0(\u0432\u0442\u043e\u0440\u043e\u0439\u00a0\u0447\u0430\u0441\u0442\u0438).<\/p>\n<p>\u041d\u0430\u0437\u043e\u0432\u0435\u043c\u00a0\u0435\u0435\u00a0<code>csv2<\/code><\/p>\n<p>\u0418\u00a0\u0442\u0435\u043f\u0435\u0440\u044c\u00a0\u043f\u043e\u043b\u043d\u044b\u0439\u00a0\u043a\u043e\u0434,\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439\u00a0\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u00a0\u0434\u0430\u043d\u043d\u044b\u0435\u00a0\u0438\u0437\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0xml\u00a0\u0432\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0csv2\u00a0(\u0441\u00a0\u043d\u0430\u0448\u0438\u043c\u00a0\u043d\u043e\u0432\u044b\u043c\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c)<\/p>\n<pre><code class=\"python\"># D:\\2021_8_16_oborot\\part2\\2021.10.20_dir_xml_to_dir_csv_with_check_name_cell.py  import os import xml.etree.ElementTree as Xet  def parse_dii():     path = 'D:\/2021_8_16_oborot\/ish_unziped\/'     fileList = os.listdir(path)     for t in fileList:         with open('D:\/2021_8_16_oborot\/ish_unziped\/' + t, 'r', encoding='utf-8') as ft:             base = os.path.splitext(t)[0]             with open(('D:\/2021_8_16_oborot\/csv2\/' + base + '.csv'), 'w+', encoding='utf-8') as f:                 xmlparse = Xet.parse('D:\/2021_8_16_oborot\/ish_unziped\/' + t)                 root = xmlparse.getroot()                 for i in root:                     for i2 in i.findall('\u0421\u0432\u0435\u0434\u041d\u041f'):                         f.writelines(i2.attrib['\u041d\u0430\u0438\u043c\u041e\u0440\u0433'])                         f.write('|')                         f.writelines(i2.attrib['\u0418\u041d\u041d\u042e\u041b'])                         f.write('|')                           for i2 in i.findall('\u0421\u0432\u0435\u0434\u0414\u043e\u0445\u0420\u0430\u0441\u0445'):                             f.writelines(i2.attrib['\u0421\u0443\u043c\u0414\u043e\u0445\u043e\u0434'])                             f.write('|')                             f.writelines(i2.attrib['\u0421\u0443\u043c\u0420\u0430\u0441\u0445\u043e\u0434'])                             f.write('\\n')                       if __name__ == '__main__':     parse_dii()<\/code><\/pre>\n<h2>\u0418\u043c\u043f\u043e\u0440\u0442 \u0432\u0441\u0435\u0445 csv \u0432 sqlite<\/h2>\n<p>\u041d\u0443,\u00a0\u0430\u00a0\u0442\u0435\u043f\u0435\u0440\u044c\u00a0\u0432\u00a0\u0446\u0438\u043a\u043b\u0435\u00a0\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u00a0\u0432\u0441\u0435\u00a0\u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f\u00a0csv\u00a0\u0444\u0430\u0439\u043b\u044b\u00a0\u0438\u0437\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0csv2\u00a0\u0438\u00a0\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u00a0\u0434\u0430\u043d\u043d\u044b\u0435\u00a0\u0432\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0443\u00a0SQLite.<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\20.10.2021_import_dir_csv_to_sqlite_with_new_delimiter.py  import sqlite3 import csv import os  def create_db_table():     conn = sqlite3.connect('D:\/2021_8_16_oborot\/UL12.db')     c = conn.cursor()      # Create table     c.execute('''CREATE TABLE IF NOT EXISTS oborot_2019_fns13               (name_UL text, inn_UL int, oborot_2019 real, rashod_2019 real)''')  # ??? real==>>int???                 #commit the changes to db     conn.commit()     #close the connection     conn.close()  def import_csv_to_sqlite():      con = sqlite3.connect('D:\/2021_8_16_oborot\/UL12.db')     cur = con.cursor()          path_D = 'D:\/2021_8_16_oborot\/csv2'     file_List = os.listdir(path_D)     for x in file_List:         with open('D:\/2021_8_16_oborot\/csv2\/'+x, 'r', encoding='utf-8') as f_in:             rows = csv.reader(f_in, delimiter=\"|\")              for row in rows:                 cur.execute('INSERT INTO oborot_2019_fns13 VALUES (?, ?, ?, ?)', row)      con.commit()     con.close()                    if __name__ == '__main__':     create_db_table()     import_csv_to_sqlite()<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043d\u0430\u0441 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 <strong>\u0411\u041e\u041b\u042c\u0428\u041e\u0419 \u0421\u042e\u0420\u041f\u0420\u0418\u0417!<\/strong> \u041a\u043e\u0434 \u0432\u044b\u043b\u0435\u0442\u0430\u0435\u0442 \u0441 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435\u043c: <code>sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 4, and there are 1 supplied.<\/code><\/p>\n<p>\u0427\u0442\u043e \u0432 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0435 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: &#171;\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 sqlite3: \u041f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u0438\u0432\u044f\u0437\u043e\u043a. \u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f 4 (\u0447\u0435\u0442\u044b\u0440\u0435), \u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e 1(\u043e\u0434\u043d\u043e).  <\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e 1(\u043e\u0434\u043d\u043e) \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043c\u044b \u0436\u0435 \u0434\u0430\u0435\u043c 4 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f 4 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0432 sqlite? <\/p>\n<p>\u0418 \u0434\u0430, \u043f\u043e\u0441\u0442\u043e\u0439\u0442\u0435, \u043d\u043e \u043c\u044b \u0436\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b\u0438 \u043a\u043e\u0434 \u0438 \u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0422\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u0434 (\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438) \u0438 \u0442\u0430\u043c \u0432\u0441\u0435 \u0431\u044b\u043b\u043e \u0433\u0443\u0434. \u041a\u0430\u043a \u0442\u0430\u043a\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c? \u041d\u0430\u0434\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0433\u0443\u0433\u043b\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0436\u0435  \u044d\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0430 \u0437\u0430\u043d\u044f\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0410 \u0432\u0441\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e <strong>\u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438.<\/strong> <\/p>\n<p><strong>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u0435\u0439: \u0433\u0434\u0435 \u0436\u0435 \u0442\u0443\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u043a\u0430\u043a \u043e\u0442 \u043d\u0435\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f? \u0415\u0441\u0442\u044c \u0438\u0434\u0435\u0438? <\/strong><code>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438.<\/code><\/p>\n<p><strong><em>\u0418 \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u044f\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u043c\u043e\u0432: &#171;\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442&#8230;&#187;<\/em><\/strong><\/p>\n<p><strong><u>P.S. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0441\u044c\u0431\u0430 (\u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e) \u0434\u043b\u044f \u0434\u043e\u0433\u0430\u0434\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0438\u043b\u0438 \u0437\u043d\u0430\u044e\u0449\u0438\u0445 \u0432 \u0447\u0435\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043e\u0448\u0438\u0431\u043a\u0438: \u043f\u0438\u0448\u0438\u0442\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043d\u0435 \u0432 \u043b\u0438\u0447\u043a\u0443. \u0410 \u0442\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044f\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0433\u0443\u0433\u043b\u0438\u0442\u044c, \u0434\u0443\u043c\u0430\u0442\u044c \u0438 \u0440\u0435\u0448\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u043a\u0443, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e.<\/u><\/strong><\/p>\n<p><code>\u0412\u0441\u0435\u043c \u0434\u043e\u0431\u0440\u0430!<\/code> <\/p>\n<p>\u0421 \u0443\u0432\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u0412\u0430\u0448 nasingfaund.<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/577148\/\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0427\u0430\u0441\u0442\u044c1. &#171;\u041f\u0430\u0440\u0441\u0438\u043c \u0431\u0430\u0437\u0443 \u044e\u0440\u0438\u043a\u043e\u0432 \u0424\u041d\u0421 (\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0441 xml, csv, SQLite \u0438 \u041f\u0438\u0442\u043e\u043d\u043e\u043c)&#187;<\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/588066\/\" rel=\"noopener noreferrer nofollow\">\u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0442\u0440\u0438\u043b\u043e\u0433\u0438\u0438 \u0442\u0443\u0442 (\u0447\u0430\u0441\u0442\u044c 3): &#171;\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e-\u043f\u0438\u0442\u043e\u043d\u0438\u0439 \u0431\u043e\u0439 \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 sqlite \u0437\u0430 2 174 433 \u0441\u0442\u0440\u043e\u0447\u043a\u0438. \u0427\u0430\u0441\u0442\u044c 3&#187;<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/585592\/\"> https:\/\/habr.com\/ru\/articles\/585592\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435.<\/em><\/strong><em>\u00a0\u041a\u0430\u043a\u00a0\u0438\u00a0<\/em><a href=\"https:\/\/habr.com\/ru\/post\/577148\/\" rel=\"noopener noreferrer nofollow\"><em>\u043f\u0435\u0440\u0432\u0430\u044f\u00a0\u0447\u0430\u0441\u0442\u044c<\/em><\/a><em>\u00a0\u044d\u0442\u0430\u00a0\u0442\u043e\u0436\u0435\u00a0\u0434\u043b\u044f\u00a0\u0441\u043e\u0432\u0441\u0435\u043c\u00a0\u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445\u00a0\u043a\u043e\u0434\u0435\u0440\u043e\u0432-\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u0435\u0439\u00a0\u043d\u0430\u00a0\u041f\u0438\u0442\u043e\u043d\u0435.\u00a0\u0414\u043b\u044f\u00a0\u043f\u0440\u043e\u0436\u0436\u0435\u043d\u043d\u044b\u0445\u00a0\u043a\u043e\u0434\u0435\u0440\u043e\u0432\u00a0\u0431\u0443\u0434\u0435\u0442\u00a0\u0441\u043a\u0443\u0447\u043d\u043e.\u00a0<\/em>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u00a0\u0445\u043e\u0442\u0435\u043b\u0438\u00a0\u0432\u043d\u0435\u0441\u0442\u0438\u00a0\u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u00a0\u0441\u0440\u0430\u0437\u0443 \u0432\u00a0\u043f\u0435\u0440\u0432\u0443\u044e\u00a0\u0441\u0442\u0430\u0442\u044c\u044e\u00a0\u043f\u043e\u00a0\u043c\u0435\u0440\u0435\u00a0\u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f\u00a0\u043e\u0448\u0438\u0431\u043e\u043a, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u0430\u0437\u0434\u0443\u043c\u0438\u044f \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e. \u041e\u0448\u0438\u0431\u043a\u0438 \u0438\u0441\u0447\u0435\u0437\u043d\u0443\u0442 \u0441\u043e\u0432\u0441\u0435\u043c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438\u043d\u043e\u0441\u044f\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u0443 \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0435\u0440\u0430. \u0410 \u043f\u043e\u0441\u0435\u043c\u0443 \u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0430 \u0432 \u044d\u0442\u043e\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043e\u0442 \u043d\u0438\u0445 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/588066\/\" rel=\"noopener noreferrer nofollow\">\u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 \u0442\u0440\u0438\u043b\u043e\u0433\u0438\u0438 \u0442\u0443\u0442 (\u0447\u0430\u0441\u0442\u044c 3): &#171;\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e-\u043f\u0438\u0442\u043e\u043d\u0438\u0439 \u0431\u043e\u0439 \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 sqlite \u0437\u0430 2 174 433 \u0441\u0442\u0440\u043e\u0447\u043a\u0438. \u0427\u0430\u0441\u0442\u044c 3&#187;<\/a><\/p>\n<h2>\u041d\u0430\u0447\u0430\u043b\u043e<\/h2>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430\u00a0\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c\u00a0\u0432\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u00a0\u043f\u0440\u043e\u0435\u043a\u0442\u0435\u00a0\u043d\u043e\u0432\u0443\u044e\u00a0\u043f\u0430\u043f\u043a\u0443,\u00a0\u043a\u0443\u0434\u0430\u00a0\u0431\u0443\u0434\u0435\u043c\u00a0\u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c\u00a0\u0432\u0435\u0441\u044c\u00a0\u043a\u043e\u0434\u00a0\u0438\u0437\u00a0\u044d\u0442\u043e\u0439\u00a0\u0441\u0442\u0430\u0442\u044c\u0438.\u00a0\u0417\u0430\u0445\u043e\u0434\u0438\u043c\u00a0\u0432\u00a0\u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e\u00a0\u0441\u0442\u0440\u043e\u043a\u0443\u00a0\u0432\u0438\u043d\u0434\u043e\u0432\u0441\u00a0\u043f\u043e\u0434\u00a0\u0430\u0434\u043c\u0438\u043d\u043e\u043c:<\/p>\n<p><code>D:\\2021_8_16_oborot>mkdir\u00a0part2<\/code><\/p>\n<p>\u0414\u0430\u043b\u0435\u0435\u00a0\u0438\u0434\u0435\u043c\u00a0\u043f\u043e\u00a0\u043f\u043e\u0440\u044f\u0434\u043a\u0443.\u00a0\u041c\u044b\u00a0\u0445\u043e\u0442\u0435\u043b\u0438\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u00a0\u043b\u0438\u00a0<code>\u0412\u0421\u0415<\/code>\u00a0\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435\u00a0xml-\u0444\u0430\u0439\u043b\u044b\u00a0\u0441\u0432\u043e\u0435\u043c\u0443\u00a0xsd\u00a0\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e.\u00a0<\/p>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 xml \u0444\u0430\u0439\u043b\u044b<\/h2>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c? \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441 xml-\u0444\u0430\u0439\u043b\u0430\u043c\u0438 (&#8230;\/ish_unziped) \u0441 xsd \u0441\u0445\u0435\u043c\u043e\u0439. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0433\u0443\u0434 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0438\u043c\u044f \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u0438\u043d\u0430\u0447\u0435 \u043a \u043f\u043b\u043e\u0445\u0438\u043c.<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\14.09.2021_check_all_xml_files_in_dir.py  import lxml from lxml import etree import os import xml.etree.ElementTree as Xet  def s_errors():     path = 'D:\/2021_8_16_oborot\/ish_unziped\/'     filelist = os.listdir(path)     enu = 0     mis = 0     with open('D:\/2021_8_16_oborot\/part2\/xml_not_valid_errors_2.txt', 'a+', encoding='utf-8') as ef:         with open('D:\/2021_8_16_oborot\/part2\/xml_is_valid_2.txt', 'a+', encoding='utf-8') as va_f:             for t in filelist:                 enu = enu + 1                          with open('D:\/2021_8_16_oborot\/ish_unziped\/' + t, 'r', encoding='utf-8') as ft:                     xml_file = lxml.etree.parse(ft)                     xml_validator = lxml.etree.XMLSchema(file='D:\/2021_8_16_oborot\/structure-20180110.xsd')                     is_valid = xml_validator.validate(xml_file)                                      if is_valid == True:                         enu1 = str(enu)                         va_f.write(enu1)                         va_f.write(':::')                         va_f.write(t)                         va_f.write('|')                         va_f.write('file_matches_xsd')                         va_f.write('\\n')                                               else:                         enu1 = str(enu)                         mis = mis + 1                         mis_str = str(mis)                         ef.write(enu1)                         ef.write(':::')                         ef.write(t)                         ef.write('the_file_does_not_match_the_xsd_schema')                         ef.write('\\n')                          if __name__ == '__main__':     s_errors()<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:\u00a0&#171;\u043f\u043b\u043e\u0445\u043e\u0439&#187;\u00a0\u0444\u0430\u0439\u043b\u00a0\u043f\u0443\u0441\u0442\u043e\u0439,\u00a0\u0432\u00a0\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u00a0\u0432\u0441\u0435\u00a012060 +1\u00a0\u0444\u0430\u0439\u043b (\u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u043c\u044b \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b\u0438!!!),\u00a0\u0438\u0442\u043e\u0433\u043e\u00a012061\u00a0\u0433\u0443\u0434\u00a0\u0444\u0430\u0439\u043b.\u00a0<\/p>\n<p>\u0412\u0438\u0434\u00a0\u0437\u0430\u043f\u0438\u0441\u0435\u0439\u00a0\u0442\u0430\u043a\u043e\u0439 (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 5 \u0441\u0442\u0440\u043e\u0447\u0435\u043a)<\/p>\n<pre><code class=\"python\">12057:::VO_OTKRDAN5_9965_9965_20210729_ffdf4a61-dc58-451e-8c76-46d63b534694.xml|file_matches_xsd 12058:::VO_OTKRDAN5_9965_9965_20210729_ffe07802-f596-46a2-aff3-24293c5162c0.xml|file_matches_xsd 12059:::VO_OTKRDAN5_9965_9965_20210729_ffe103cb-571e-4c05-9395-6d97814e6100.xml|file_matches_xsd 12060:::VO_OTKRDAN5_9965_9965_20210729_ffe3f7a0-c0db-4c6a-a231-98a429c51314.xml|file_matches_xsd 12061:::VO_OTKRDAN5_9965_9965_20210729_ffec8ca1-4e5d-42ea-ad3e-2ac45146da0d.xml|file_matches_xsd<\/code><\/pre>\n<p><strong><em>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/em><\/strong><em>. \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0437\u0436\u0435 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0435 \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u043e\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u044f &#171;\u0431\u0438\u0442\u044b\u0445&#187; \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u0440\u0442\u0438\u0442\u044c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 \u0432 csv \u0438 \u0434\u0430\u043b\u0435\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 sqlite.<\/em><\/p>\n<h2>\u041f\u0438\u0448\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442 xml \u0432 csv \u0438 \u0434\u0430\u043b\u0435\u0435 \u0432 sqlite \u043d\u0430 \u041f\u0438\u0442\u043e\u043d\u0435<\/h2>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0442\u043e\u0440\u043e\u043f\u0438\u043b\u0438\u0441\u044c \u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0432\u044b\u044f\u0441\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u043c\u044b \u0442\u0430\u043c \u043d\u0435 \u0442\u043e \u043d\u0430\u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0438\u043b\u0438 \u0432 \u041f\u0438\u0442\u043e\u043d\u0435 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 csv \u0432 sqlite, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e  &#8216;\u043f\u0435\u0440\u0435\u043f\u0440\u044b\u0433\u043d\u0443\u043b\u0438&#8217; \u0434\u0430\u043b\u044c\u0448\u0435 \u043a \u0444\u0438\u043d\u0438\u0448\u0443. \u0418\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f. \u0412\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f\u00a0\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u00a0\u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0430\u0439\u043f-pipe (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0424\u0438\u0433\u0443\u0440\u043d\u043e\u0432 \u043f\u0435\u0440\u0435\u0432\u0435\u043b, \u043a\u0430\u043a &#8216;\u0441\u0438\u043c\u0432\u043e\u043b \u0432\u043e\u0434\u043e\u043f\u0440\u043e\u0432\u043e\u0434\u0430&#8217;): <code>\"|\".<\/code> \u041f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 (\u043a\u0430\u043a \u043f\u043e\u0437\u0436\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0437\u0440\u044f), \u0447\u0442\u043e \u0432\u0440\u044f\u0434-\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043c\u043e\u0436\u0435\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f &#171;\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438 &#8216;\u043d\u0438\u043a\u043e\u0433\u0434\u0430&#8217;. \u041f\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043b\u0435\u043d\u044c \u0432 \u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445.\u00a0\u041f\u043e\u0447\u0435\u043c\u0443 \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u0437\u0430\u043f\u044f\u0442\u0443\u044e <code>(\",\")<\/code>? \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438, \u043d\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432 \u0438\u043c\u0435\u043d\u0430\u0445 \u042e\u041b \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u044f\u0442\u044b\u0445 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e. \u0418 \u043f\u0440\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0435 \u0432 sqlite \u044d\u0442\u0438 \u0437\u0430\u043f\u044f\u0442\u044b\u0435 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u044c \u0442\u043e\u0436\u0435 \u043a\u0430\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0438 \u043b\u043e\u043c\u0430\u043b\u0438 \u0432\u0435\u0441\u044c \u0438\u043c\u043f\u043e\u0440\u0442. \u041f\u043e\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0439\u043f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044f. \u0421\u0430\u043c\u0430 \u0441\u0445\u0435\u043c\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0441\u0442\u0430\u0440\u043e\u0439, \u043a\u0430\u043a \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c xml \u0432 csv, \u0430 \u043f\u043e\u0442\u043e\u043c csv \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 sqlite. \u0422\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c \u0434\u0440\u0443\u0433\u043e\u0439. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u0434 \u043d\u0430 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a &#8212; \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0438 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u043c\u043f\u043e\u0440\u0442 xml \u0432 csv<\/h2>\n<p>\u041d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 xml \u0432 csv. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438.<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\20.10.2021_mini_test_one_file_xml_to_csv_with_new_delimiter.py  import xml.etree.ElementTree as Xet  f = open('18_your_csv_file.csv', 'w', encoding='utf-8')  xmlparse = Xet.parse('D:\/2021_8_16_oborot\/ish_unziped\/test1.xml') root = xmlparse.getroot()   for i in root:     for i2 in i.findall('\u0421\u0432\u0435\u0434\u041d\u041f'):         f.writelines(i2.attrib['\u041d\u0430\u0438\u043c\u041e\u0440\u0433'])         f.write('|')         f.writelines(i2.attrib['\u0418\u041d\u041d\u042e\u041b'])         f.write('|')         #f.write('\\n')         for i2 in i.findall('\u0421\u0432\u0435\u0434\u0414\u043e\u0445\u0420\u0430\u0441\u0445'):             f.writelines(i2.attrib['\u0421\u0443\u043c\u0414\u043e\u0445\u043e\u0434'])             f.write('|')             f.writelines(i2.attrib['\u0421\u0443\u043c\u0420\u0430\u0441\u0445\u043e\u0434'])             f.write('\\n')                   f.close()<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u00a0\u043d\u043e\u0440\u043c,\u00a0\u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code>\u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e  \"\u0424\u0418\u0411\u0420\u041e\u0422\u0415\u041a\"|7816394401|0.00|0.00 \u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e \"\u0418\u0417\u0414\u0410\u0422\u0415\u041b\u042c\u0421\u041a\u0418\u0419 \u0414\u041e\u041c \"\u0422\u0412\u0415\u0420\u0421\u041a\u0410\u042f \u0416\u0418\u0417\u041d\u042c\"|6901026686|0.00|0.00 \u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e \"\u041c\u0420\u0410\u0412\"|7726503712|20800000.00|14102000.00 \u041e\u0411\u0429\u0415\u0421\u0422\u0412\u041e \u0421 \u041e\u0413\u0420\u0410\u041d\u0418\u0427\u0415\u041d\u041d\u041e\u0419 \u041e\u0422\u0412\u0415\u0422\u0421\u0422\u0412\u0415\u041d\u041d\u041e\u0421\u0422\u042c\u042e \"\u0410\u0413\u0420\u041e\u0420\u0415\u0421\u0423\u0420\u0421\"|6901026703|470000.00|461000.00<\/code><\/pre>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u043c\u043f\u043e\u0440\u0442 csv \u0432 table sqlite<\/h2>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0442\u0435\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u043e\u0434\u043d\u043e\u0433\u043e (\u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e) csv \u0444\u0430\u0439\u043b\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 sqlite. \u00a0<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\25.10.2021_mini_test_csv_to_sqlite_with_new_delimiter.py  import sqlite3 import csv import os  def create_db_table():     conn = sqlite3.connect('D:\/2021_8_16_oborot\/UL11.db')     c = conn.cursor()      # Create table     c.execute('''CREATE TABLE IF NOT EXISTS oborot_2019_fns12               (name_UL text, inn_UL int, oborot_2019 real, rashod_2019 real)''')  # ??? real==>>int???                 #commit the changes to db     conn.commit()     #close the connection     conn.close()  def import_one_file_csv_to_sqlite():      con = sqlite3.connect('D:\/2021_8_16_oborot\/UL11.db')     cur = con.cursor()      with open('D:\/2021_8_16_oborot\/part2\/19_your_csv_file.csv', 'r', encoding='utf-8') as f_open_csv:         rows = csv.reader(f_open_csv, delimiter=\"|\")                  for row in rows:             cur.execute('INSERT INTO oborot_2019_fns12 VALUES (?, ?, ?, ?)', row)      con.commit()     con.close()                      if __name__ == '__main__':     create_db_table()     import_one_file_csv_to_sqlite()<\/code><\/pre>\n<p>\u0412\u0441\u0435\u00a0\u0433\u0443\u0434,\u00a0\u0434\u0430\u043d\u043d\u044b\u0435\u00a0\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f\u00a0\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e.\u00a0\u0414\u0430\u043d\u043d\u044b\u0435\u00a0\u0432\u00a0\u0441\u0432\u043e\u0438\u0445\u00a0\u043f\u043e\u043b\u044f\u0445,\u00a0\u043d\u0435\u00a0\u043b\u0435\u0437\u0443\u0442\u00a0\u0432\u00a0\u0447\u0443\u0436\u0438\u0435.<\/p>\n<h2>\u0418\u043c\u043f\u043e\u0440\u0442 \u0432\u0441\u0435\u0445 xml \u0432 csv2 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c\u00a0\u0434\u0435\u043b\u0430\u0435\u043c\u00a0\u0442\u043e\u0436\u0435\u00a0\u0441\u0430\u043c\u043e\u0435,\u00a0\u043d\u043e\u00a0\u0447\u0438\u0442\u0430\u0435\u043c\u00a0\u0432\u0441\u0435\u00a0\u0444\u0430\u0439\u043b\u044b\u00a0\u0438\u0437\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0xml (&#8230;\/ish_unziped)\u00a0\u0432\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0csv.\u00a0\u0427\u0442\u043e\u0431\u044b\u00a0\u043d\u0435\u00a0\u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f\u00a0\u0441\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0435\u0439\u00a0\u0438\u0437\u00a0\u043f\u0435\u0440\u0432\u043e\u0439\u00a0\u0447\u0430\u0441\u0442\u0438\u00a0 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0\u043f\u043e\u0434\u00a0csv\u00a0\u0444\u0430\u0439\u043b\u044b\u00a0\u0438\u0437\u00a0\u0442\u0435\u043a\u0443\u0449\u0435\u0439\u00a0(\u0432\u0442\u043e\u0440\u043e\u0439\u00a0\u0447\u0430\u0441\u0442\u0438).<\/p>\n<p>\u041d\u0430\u0437\u043e\u0432\u0435\u043c\u00a0\u0435\u0435\u00a0<code>csv2<\/code><\/p>\n<p>\u0418\u00a0\u0442\u0435\u043f\u0435\u0440\u044c\u00a0\u043f\u043e\u043b\u043d\u044b\u0439\u00a0\u043a\u043e\u0434,\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439\u00a0\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442\u00a0\u0434\u0430\u043d\u043d\u044b\u0435\u00a0\u0438\u0437\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0xml\u00a0\u0432\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e\u00a0csv2\u00a0(\u0441\u00a0\u043d\u0430\u0448\u0438\u043c\u00a0\u043d\u043e\u0432\u044b\u043c\u00a0\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c)<\/p>\n<pre><code class=\"python\"># D:\\2021_8_16_oborot\\part2\\2021.10.20_dir_xml_to_dir_csv_with_check_name_cell.py  import os import xml.etree.ElementTree as Xet  def parse_dii():     path = 'D:\/2021_8_16_oborot\/ish_unziped\/'     fileList = os.listdir(path)     for t in fileList:         with open('D:\/2021_8_16_oborot\/ish_unziped\/' + t, 'r', encoding='utf-8') as ft:             base = os.path.splitext(t)[0]             with open(('D:\/2021_8_16_oborot\/csv2\/' + base + '.csv'), 'w+', encoding='utf-8') as f:                 xmlparse = Xet.parse('D:\/2021_8_16_oborot\/ish_unziped\/' + t)                 root = xmlparse.getroot()                 for i in root:                     for i2 in i.findall('\u0421\u0432\u0435\u0434\u041d\u041f'):                         f.writelines(i2.attrib['\u041d\u0430\u0438\u043c\u041e\u0440\u0433'])                         f.write('|')                         f.writelines(i2.attrib['\u0418\u041d\u041d\u042e\u041b'])                         f.write('|')                           for i2 in i.findall('\u0421\u0432\u0435\u0434\u0414\u043e\u0445\u0420\u0430\u0441\u0445'):                             f.writelines(i2.attrib['\u0421\u0443\u043c\u0414\u043e\u0445\u043e\u0434'])                             f.write('|')                             f.writelines(i2.attrib['\u0421\u0443\u043c\u0420\u0430\u0441\u0445\u043e\u0434'])                             f.write('\\n')                       if __name__ == '__main__':     parse_dii()<\/code><\/pre>\n<h2>\u0418\u043c\u043f\u043e\u0440\u0442 \u0432\u0441\u0435\u0445 csv \u0432 sqlite<\/h2>\n<p>\u041d\u0443,\u00a0\u0430\u00a0\u0442\u0435\u043f\u0435\u0440\u044c\u00a0\u0432\u00a0\u0446\u0438\u043a\u043b\u0435\u00a0\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u00a0\u0432\u0441\u0435\u00a0\u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0435\u0441\u044f\u00a0csv\u00a0\u0444\u0430\u0439\u043b\u044b\u00a0\u0438\u0437\u00a0\u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438\u00a0csv2\u00a0\u0438\u00a0\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u00a0\u0434\u0430\u043d\u043d\u044b\u0435\u00a0\u0432\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0443\u00a0SQLite.<\/p>\n<pre><code class=\"python\">#D:\\2021_8_16_oborot\\part2\\20.10.2021_import_dir_csv_to_sqlite_with_new_delimiter.py  import sqlite3 import csv import os  def create_db_table():     conn = sqlite3.connect('D:\/2021_8_16_oborot\/UL12.db')     c = conn.cursor()      # Create table     c.execute('''CREATE TABLE IF NOT EXISTS oborot_2019_fns13               (name_UL text, inn_UL int, oborot_2019 real, rashod_2019 real)''')  # ??? real==>>int???                 #commit the changes to db     conn.commit()     #close the connection     conn.close()  def import_csv_to_sqlite():      con = sqlite3.connect('D:\/2021_8_16_oborot\/UL12.db')     cur = con.cursor()          path_D = 'D:\/2021_8_16_oborot\/csv2'     file_List = os.listdir(path_D)     for x in file_List:         with open('D:\/2021_8_16_oborot\/csv2\/'+x, 'r', encoding='utf-8') as f_in:             rows = csv.reader(f_in, delimiter=\"|\")              for row in rows:                 cur.execute('INSERT INTO oborot_2019_fns13 VALUES (?, ?, ?, ?)', row)      con.commit()     con.close()                    if <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-400629","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/400629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=400629"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/400629\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=400629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=400629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=400629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}