{"id":43837,"date":"2021-09-23T14:37:14","date_gmt":"2021-09-23T12:37:14","guid":{"rendered":"https:\/\/eiposgrados.com\/?p=43837"},"modified":"2021-10-29T16:01:36","modified_gmt":"2021-10-29T14:01:36","slug":"script-csv-file-python","status":"publish","type":"post","link":"https:\/\/eiposgrados.com\/eng\/python-blog\/script-csv-file-python\/","title":{"rendered":"Script to create CSV file with Python"},"content":{"rendered":"<p>CSV (Comma Separated Values) files are a type of simple text document used to represent data in tabular form, where columns are separated by commas or semicolons and rows by line breaks.<\/p>\n\n\n\n<p>CSV files are usually used to handle a large amount of data in table format, since being so lightweight, they do not generate much processing load.<\/p>\n\n\n\n<p>That&#039;s why we&#039;re going to learn how to automatically create our CSV file with a few lines of code.&nbsp;<\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-d9c6b0b5 gb-headline-text\">How to automatically create a CSV file with Python<\/h2>\n\n\n\n<p><img decoding=\"async\" width=\"100%\" src=\"https:\/\/lh3.googleusercontent.com\/aQ1-frFeyai0M37cbfpL0D5kZDJKmwgM51LmDlnD5ryZxnW2VyvZMWS8r-Yc4INljjKyQCrTbygDUZPol4BtEI-gTqOfIoHmhJwHE3uAEhgMK5kylPiP06BoGDrIW5evDii3iCVxXp0Hnc0L3w=s0\" alt=\"\" title=\"\"><\/p>\n\n\n\n<p>We will import the CSV module, we will create our header fields with <strong><em>fieldnames <\/em><\/strong>and later we will write each row indicating the data of each one.<\/p>\n\n\n\n<p>Finally we will launch a message on the screen showing that the data has been inserted.<\/p>\n\n\n\n<p>In this simple way, a csv file will be created in the same folder with the data we inserted. Whenever we want to create a csv file with any data, we can run this script by simply updating the data.&nbsp;<\/p>\n\n\n\n<p>We can modify it so that it collects data from a file or collects it by keyboard, but that will be later.<\/p>","protected":false},"excerpt":{"rendered":"<p>In this blog post we explain how to create a CSV file with Python. <\/p>","protected":false},"author":1,"featured_media":51558,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[407],"tags":[],"class_list":["post-43837","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-python"],"acf":[],"_links":{"self":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/43837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/comments?post=43837"}],"version-history":[{"count":0,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/posts\/43837\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media\/51558"}],"wp:attachment":[{"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/media?parent=43837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/categories?post=43837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eiposgrados.com\/eng\/wp-json\/wp\/v2\/tags?post=43837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}