{"id":207,"date":"2018-01-01T23:39:00","date_gmt":"2018-01-01T22:39:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/2018\/01\/01\/how-to-connect-python-to-excel-read-and-write-data-try-it\/"},"modified":"2020-08-22T11:05:40","modified_gmt":"2020-08-22T09:05:40","slug":"how-to-connect-python-to-excel-read-and-write-data-try-it","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/how-to-connect-python-to-excel-read-and-write-data-try-it\/","title":{"rendered":"How to Connect Python to Excel &#8211; Read and Write Data (Try it!)"},"content":{"rendered":"<p>In this tutorial, we would examine how to use Python to create an excel csv file, write data into it, read records from the file and delete records from it.<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/2.bp.blogspot.com\/-eNtMgneEhZo\/Wkqxxh6R0NI\/AAAAAAAAAlc\/uxnoEmoQY5wtaLC9iY9ToUXujIoEi8zCwCLcBGAs\/s1600\/How-to-Connect-Python-to-Excel-Read-and-Write-Data.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/2.bp.blogspot.com\/-eNtMgneEhZo\/Wkqxxh6R0NI\/AAAAAAAAAlc\/uxnoEmoQY5wtaLC9iY9ToUXujIoEi8zCwCLcBGAs\/s320\/How-to-Connect-Python-to-Excel-Read-and-Write-Data.jpg\" width=\"320\" height=\"164\" border=\"0\" data-original-height=\"703\" data-original-width=\"1367\" \/><\/a><\/div>\n<p>To demonstrate how this works, we would build a book databases that would allow us to perform the following operations:<\/p>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=JwZtTk6Hr80&amp;feature=youtu.be\">Watch video here<\/a><\/p>\n<ul>\n<li>Add New Book<\/li>\n<li>Display list of books<\/li>\n<li>Search for book<\/li>\n<li>Retrieve a particular record<\/li>\n<li>Delete a book<\/li>\n<li>Get to total number of books<\/li>\n<\/ul>\n<p>The output screen of the program would be as shown below:<\/p>\n<div style=\"clear: both; text-align: center;\"><a style=\"margin-left: 1em; margin-right: 1em;\" href=\"https:\/\/4.bp.blogspot.com\/-dhtpxtjv4XI\/WkqxZ7U3bvI\/AAAAAAAAAlY\/t5AND7tamqsuJsvSucE-NN-NidT6LUUmACLcBGAs\/s1600\/Connect-Python-To-Excel-Screenshot.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/4.bp.blogspot.com\/-dhtpxtjv4XI\/WkqxZ7U3bvI\/AAAAAAAAAlY\/t5AND7tamqsuJsvSucE-NN-NidT6LUUmACLcBGAs\/s400\/Connect-Python-To-Excel-Screenshot.jpg\" width=\"400\" height=\"172\" border=\"0\" data-original-height=\"379\" data-original-width=\"877\" \/><\/a><\/div>\n<p>This program would not really be difficult as the design would be modular with different functions to perform different operations. Let&#8217;s take a look at all the functions.<\/p>\n<p>&nbsp;<\/p>\n<p><b>1. SaveBook(book)<\/b><br \/>\nThis function takes a book record as parameter and writes the record into the file<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\"># FUNCTION TO SAVE BOOK TO FILE<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">SaveBook<\/span>(book):\r\n    f <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">\"BookData.csv\"<\/span>,<span style=\"background-color: #fff0f0;\">\"a+\"<\/span>)\r\n    f<span style=\"color: #333333;\">.<\/span>write(book[<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">','<\/span> <span style=\"color: #333333;\">+<\/span> book[<span style=\"color: #0000dd; font-weight: bold;\">1<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">','<\/span> <span style=\"color: #333333;\">+<\/span> book[<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">','<\/span> <span style=\"color: #333333;\">+<\/span> book[<span style=\"color: #0000dd; font-weight: bold;\">3<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">'<\/span>)\r\n    f<span style=\"color: #333333;\">.<\/span>close()<\/pre>\n<p>&nbsp;<\/p>\n<p><b>2. GetRecord()<\/b><br \/>\nThis function accept id as parameter, then searches the database to retrieve the record with the given id<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">#  FUNCTION TO RETRIEVE A SINGLE BOOK RECORD FROM THE DATABASE<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">GetRecord<\/span>(input_id):\r\n    <span style=\"color: #008800; font-weight: bold;\">with<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">\"BookData.csv\"<\/span>,<span style=\"background-color: #fff0f0;\">\"r\"<\/span>) <span style=\"color: #008800; font-weight: bold;\">as<\/span> f:\r\n         <span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> f:\r\n             line <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()\r\n             <span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">\",\"<\/span>)\r\n             <span style=\"color: #008800; font-weight: bold;\">if<\/span> (<span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">==<\/span> input_id):\r\n                 <span style=\"color: #008800; font-weight: bold;\">return<\/span> line<\/pre>\n<p>&nbsp;<\/p>\n<p><b>3. AddBook()<\/b><br \/>\nThis function prompts the user for book details. Then it calls the SaveBook() function to save the book to file<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">#  FUNCTION TO ADD A BOOK TO THE DATABASE<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">AddBook<\/span>():\r\n    Book <span style=\"color: #333333;\">=<\/span> namedtuple(<span style=\"background-color: #fff0f0;\">\"Book\"<\/span>, <span style=\"background-color: #fff0f0;\">\"ID Title Author ISBN\"<\/span>)\r\n    <span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">\"Enter the ID: \"<\/span>)\r\n    title <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">\"Enter title of book: \"<\/span>)\r\n    author <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">\"Enter name of author: \"<\/span>)\r\n    isbn <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">\"Enter ISBN: \"<\/span>)\r\n    newBook <span style=\"color: #333333;\">=<\/span> Book(<span style=\"color: #007020;\">id<\/span>, title, author, isbn)\r\n    SaveBook(newBook)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"Book was added successfullly\"<\/span>)<\/pre>\n<p>&nbsp;<\/p>\n<p><b>4. DisplayBook()<\/b><br \/>\nThis function prompts the user for an id, then it calls to the GetRecord() function to retrieve the book corresponding that id and then displays the book details<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">#  FUNCTION DISPLAY DETAILS OF A PARTICULAR BOOK<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">DisplayBook<\/span>():\r\n    input_id <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">\"Enter the ID of book to display: \"<\/span>)\r\n    <span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> GetRecord(input_id)<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">\",\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">if<\/span> (<span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">==<\/span> input_id):\r\n        <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">'{0: &lt;5}'<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #007020;\">id<\/span>) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;35}'<\/span><span style=\"color: #333333;\">.<\/span>format(title) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;25}'<\/span><span style=\"color: #333333;\">.<\/span>format(author) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;15}'<\/span><span style=\"color: #333333;\">.<\/span>format(isbn))\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><b>5. DeleteBook()<\/b><br \/>\nThis function prompt the user for an id, then it deletes the record corresponding to that id from the file<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\"># FUNCTION TO DELETE A BOOK FROM THE DATABASE<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">DeleteBook<\/span>():\r\n    input_id <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">\"Enter the ID of the book to delete: \"<\/span>)\r\n    f <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">\"BookData.csv\"<\/span>,<span style=\"background-color: #fff0f0;\">\"r+\"<\/span>)\r\n    d <span style=\"color: #333333;\">=<\/span> f<span style=\"color: #333333;\">.<\/span>readlines()\r\n    f<span style=\"color: #333333;\">.<\/span>seek(<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> d:\r\n        record <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()\r\n        <span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> record<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">\",\"<\/span>)\r\n        <span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">!=<\/span> input_id:\r\n           f<span style=\"color: #333333;\">.<\/span>write(line)\r\n    f<span style=\"color: #333333;\">.<\/span>truncate()\r\n    f<span style=\"color: #333333;\">.<\/span>close()\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"Book was successfully deleted from the database!\"<\/span>)<\/pre>\n<p>&nbsp;<\/p>\n<p><b>6. ViewBooks()<\/b><br \/>\nThis function displays all the books in the database.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\"># FUNCTION TO VIEW ALL BOOKS IN THE DATABASE<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">ViewBooks<\/span>():\r\n         <span style=\"color: #008800; font-weight: bold;\">with<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">\"BookData.csv\"<\/span>,<span style=\"background-color: #fff0f0;\">\"r\"<\/span>) <span style=\"color: #008800; font-weight: bold;\">as<\/span> f:\r\n             <span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> f:\r\n                 line <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()\r\n                 <span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">\",\"<\/span>)\r\n                 <span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: black; font-weight: bold;\">not<\/span> line: <span style=\"color: #008800; font-weight: bold;\">continue<\/span>\r\n                 <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">'{0: &lt;5}'<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #007020;\">id<\/span>) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'{0: &lt;35}'<\/span><span style=\"color: #333333;\">.<\/span>format(title) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'{0: &lt;25}'<\/span><span style=\"color: #333333;\">.<\/span>format(author) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'{0: &lt;15}'<\/span><span style=\"color: #333333;\">.<\/span>format(isbn))<\/pre>\n<p>&nbsp;<\/p>\n<p><b>7. Search()<\/b><br \/>\nThis function prompts for a search criteria. It then searches through the all the records to find a record that matches with the given criteria.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">#  FUNCTION TO SEARCH FOR A BOOK IN THE DATABASE<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Search<\/span>():\r\n    criteria <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">\"Enter a search criteria: \"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">with<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">\"BookData.csv\"<\/span>,<span style=\"background-color: #fff0f0;\">\"r\"<\/span>) <span style=\"color: #008800; font-weight: bold;\">as<\/span> f:\r\n         <span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> f:\r\n             line <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()\r\n             <span style=\"color: #008800; font-weight: bold;\">if<\/span> line<span style=\"color: #333333;\">.<\/span>upper()<span style=\"color: #333333;\">.<\/span>find(criteria<span style=\"color: #333333;\">.<\/span>upper()) <span style=\"color: #333333;\">!=<\/span> <span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span>:\r\n                 <span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">\",\"<\/span>)\r\n                 <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">'{0: &lt;5}'<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #007020;\">id<\/span>) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;35}'<\/span><span style=\"color: #333333;\">.<\/span>format(title) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;25}'<\/span><span style=\"color: #333333;\">.<\/span>format(author) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">'<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;15}'<\/span><span style=\"color: #333333;\">.<\/span>format(isbn))<\/pre>\n<p>&nbsp;<\/p>\n<p><b>8. GetTotal()<\/b><br \/>\nThis function counts the total number of books in the database.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\"># GET THE TOTAL NUMBER OF BOOKS<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">GetTotal<\/span>():\r\n        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #007020;\">sum<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">1<\/span> <span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">'BookData.csv'<\/span>))<\/pre>\n<p>&nbsp;<\/p>\n<p><b>9. DisplayMenu()<\/b><br \/>\nThis function displays the menu and allows user to make a choice of operations to perform.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">#FUNCTION TO DISPLAY THE MENU<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">DisplayMenu<\/span>():\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"CHOOSE AN OPERATION. \"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"1. ADD A BOOK\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"2. DISPLAY BOOK DETAILS\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"3. DELETE A BOOK\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"4. VIEW BOOKS\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"5. SEARCH FOR BOOK\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"6. GET TOTAL NUMBER\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">\"7. EXIT\"<\/span>)<\/pre>\n<p>&nbsp;<\/p>\n<p><b>The Complete Program<\/b><br \/>\nAfter you have taken some time to understand the various functions in the program. Then go ahead to copy the complete program and paste in your python IDE and run.<\/p>\n<p>For any observation, you can leave a comment below. Since the next revision of\u00a0 this program would be based on users&#8217; observations and recommendation, you can point out any areas you would like the program to be improved as well as any features you would like added. So we can work on the next update together.<br \/>\nYou can watch the video <a href=\"https:\/\/youtu.be\/JwZtTk6Hr80\">here<\/a>.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">sys<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">collections<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> namedtuple\r\n<span style=\"color: #888888;\">#****************************************************************************************<\/span>\r\n<span style=\"color: #888888;\">#PROGRAM BY:    KINDSON THE GENIUS                                                      *<\/span>\r\n<span style=\"color: #888888;\">#SECTION:       PYTHON TUTORIALS                                                        *<\/span>\r\n<span style=\"color: #888888;\">#DATE:          1ST JANUARY 2018                                                        *<\/span>\r\n<span style=\"color: #888888;\">#Program No.    YOUR SECOND PROGRAM IN 2018                                             *<\/span>\r\n<span style=\"color: #888888;\">#****************************************************************************************<\/span><\/pre>\n<p><span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8216;*&#8217;<\/span> <span style=\"color: #333333;\">*<\/span> <span style=\"color: #0000dd; font-weight: bold;\">75<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">**************** PROGRAM TO CREATE READ AND WRITE TO EXCEL ********************<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">nn<\/span><span style=\"background-color: #fff0f0;\">&#8220;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8216;*&#8217;<\/span> <span style=\"color: #333333;\">*<\/span> <span style=\"color: #0000dd; font-weight: bold;\">75<\/span>)<\/p>\n<p><span style=\"color: #888888;\"># FUNCTION TO SAVE BOOK TO FILE<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">SaveBook<\/span>(book):<br \/>\nf <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;BookData.csv&#8221;<\/span>,<span style=\"background-color: #fff0f0;\">&#8220;a+&#8221;<\/span>)<br \/>\nf<span style=\"color: #333333;\">.<\/span>write(book[<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;,&#8217;<\/span> <span style=\"color: #333333;\">+<\/span> book[<span style=\"color: #0000dd; font-weight: bold;\">1<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;,&#8217;<\/span> <span style=\"color: #333333;\">+<\/span> book[<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;,&#8217;<\/span> <span style=\"color: #333333;\">+<\/span> book[<span style=\"color: #0000dd; font-weight: bold;\">3<\/span>] <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">&#8216;<\/span>)<br \/>\nf<span style=\"color: #333333;\">.<\/span>close()<\/p>\n<p><span style=\"color: #888888;\"># FUNCTION TO RETRIEVE A SINGLE BOOK RECORD FROM THE DATABASE<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">GetRecord<\/span>(input_id):<br \/>\n<span style=\"color: #008800; font-weight: bold;\">with<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;BookData.csv&#8221;<\/span>,<span style=\"background-color: #fff0f0;\">&#8220;r&#8221;<\/span>) <span style=\"color: #008800; font-weight: bold;\">as<\/span> f:<br \/>\n<span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> f:<br \/>\nline <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()<br \/>\n<span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">&#8220;,&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">if<\/span> (<span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">==<\/span> input_id):<br \/>\n<span style=\"color: #008800; font-weight: bold;\">return<\/span> line<\/p>\n<p><span style=\"color: #888888;\"># FUNCTION TO ADD A BOOK TO THE DATABASE<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">AddBook<\/span>():<br \/>\nBook <span style=\"color: #333333;\">=<\/span> namedtuple(<span style=\"background-color: #fff0f0;\">&#8220;Book&#8221;<\/span>, <span style=\"background-color: #fff0f0;\">&#8220;ID Title Author ISBN&#8221;<\/span>)<br \/>\n<span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Enter the ID: &#8220;<\/span>)<br \/>\ntitle <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Enter title of book: &#8220;<\/span>)<br \/>\nauthor <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Enter name of author: &#8220;<\/span>)<br \/>\nisbn <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Enter ISBN: &#8220;<\/span>)<br \/>\nnewBook <span style=\"color: #333333;\">=<\/span> Book(<span style=\"color: #007020;\">id<\/span>, title, author, isbn)<br \/>\nSaveBook(newBook)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Book was added successfullly&#8221;<\/span>)<\/p>\n<p><span style=\"color: #888888;\"># FUNCTION DISPLAY DETAILS OF A PARTICULAR BOOK<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">DisplayBook<\/span>():<br \/>\ninput_id <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Enter the ID of book to display: &#8220;<\/span>)<br \/>\n<span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> GetRecord(input_id)<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">&#8220;,&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">if<\/span> (<span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">==<\/span> input_id):<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8216;{0: &lt;5}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #007020;\">id<\/span>) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;35}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(title) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;25}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(author) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;15}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(isbn))<\/p>\n<p><span style=\"color: #888888;\"># FUNCTION TO DELETE A BOOK FROM THE DATABASE<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">DeleteBook<\/span>():<br \/>\ninput_id <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Enter the ID of the book to delete: &#8220;<\/span>)<br \/>\nf <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;BookData.csv&#8221;<\/span>,<span style=\"background-color: #fff0f0;\">&#8220;r+&#8221;<\/span>)<br \/>\nd <span style=\"color: #333333;\">=<\/span> f<span style=\"color: #333333;\">.<\/span>readlines()<br \/>\nf<span style=\"color: #333333;\">.<\/span>seek(<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> d:<br \/>\nrecord <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()<br \/>\n<span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> record<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">&#8220;,&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: #007020;\">id<\/span> <span style=\"color: #333333;\">!=<\/span> input_id:<br \/>\nf<span style=\"color: #333333;\">.<\/span>write(line)<br \/>\nf<span style=\"color: #333333;\">.<\/span>truncate()<br \/>\nf<span style=\"color: #333333;\">.<\/span>close()<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Book was successfully deleted from the database!&#8221;<\/span>)<\/p>\n<p><span style=\"color: #888888;\"># FUNCTION TO VIEW ALL BOOKS IN THE DATABASE<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">ViewBooks<\/span>():<br \/>\n<span style=\"color: #008800; font-weight: bold;\">with<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;BookData.csv&#8221;<\/span>,<span style=\"background-color: #fff0f0;\">&#8220;r&#8221;<\/span>) <span style=\"color: #008800; font-weight: bold;\">as<\/span> f:<br \/>\n<span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> f:<br \/>\nline <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()<br \/>\n<span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">&#8220;,&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: black; font-weight: bold;\">not<\/span> line: <span style=\"color: #008800; font-weight: bold;\">continue<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8216;{0: &lt;5}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #007020;\">id<\/span>) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;{0: &lt;35}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(title) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;{0: &lt;25}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(author) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;{0: &lt;15}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(isbn))<\/p>\n<p><span style=\"color: #888888;\"># FUNCTION TO SEARCH FOR A BOOK IN THE DATABASE<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Search<\/span>():<br \/>\ncriteria <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Enter a search criteria: &#8220;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">with<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;BookData.csv&#8221;<\/span>,<span style=\"background-color: #fff0f0;\">&#8220;r&#8221;<\/span>) <span style=\"color: #008800; font-weight: bold;\">as<\/span> f:<br \/>\n<span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> f:<br \/>\nline <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>rstrip()<br \/>\n<span style=\"color: #008800; font-weight: bold;\">if<\/span> line<span style=\"color: #333333;\">.<\/span>upper()<span style=\"color: #333333;\">.<\/span>find(criteria<span style=\"color: #333333;\">.<\/span>upper()) <span style=\"color: #333333;\">!=<\/span> <span style=\"color: #333333;\">&#8211;<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span>:<br \/>\n<span style=\"color: #007020;\">id<\/span>,title,author,isbn <span style=\"color: #333333;\">=<\/span> line<span style=\"color: #333333;\">.<\/span>split(<span style=\"background-color: #fff0f0;\">&#8220;,&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8216;{0: &lt;5}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #007020;\">id<\/span>) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;35}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(title) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;25}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(author) <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">&#8216;<\/span><span style=\"background-color: #fff0f0; color: #666666; font-weight: bold;\">n<\/span><span style=\"background-color: #fff0f0;\">{0: &lt;15}&#8217;<\/span><span style=\"color: #333333;\">.<\/span>format(isbn))<\/p>\n<p><span style=\"color: #888888;\">#FUNCTION TO DISPLAY THE MENU<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">DisplayMenu<\/span>():<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;CHOOSE AN OPERATION. &#8220;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;1. ADD A BOOK&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;2. DISPLAY BOOK DETAILS&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;3. DELETE A BOOK&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;4. VIEW BOOKS&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;5. SEARCH FOR BOOK&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;6. GET TOTAL NUMBER&#8221;<\/span>)<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;7. EXIT&#8221;<\/span>)<\/p>\n<p><span style=\"color: #888888;\"># GET THE TOTAL NUMBER OF BOOKS<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">GetTotal<\/span>():<br \/>\n<span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #007020;\">sum<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">1<\/span> <span style=\"color: #008800; font-weight: bold;\">for<\/span> line <span style=\"color: black; font-weight: bold;\">in<\/span> <span style=\"color: #007020;\">open<\/span>(<span style=\"background-color: #fff0f0;\">&#8216;BookData.csv&#8217;<\/span>))<\/p>\n<p><span style=\"color: #888888;\">#*********************** BEGINING OF MAIN PROGRAM *******************<\/span><br \/>\nDisplayMenu()<\/p>\n<p><span style=\"color: #888888;\">#GET USER CHOICE<\/span><br \/>\nchoice <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">input<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Select an operation (1,2,3,4,5,6,7): &#8220;<\/span>)<\/p>\n<p><span style=\"color: #888888;\">#EXIT THE PROGRAM IF THE INPUT IS 7<\/span><br \/>\n<span style=\"color: #008800; font-weight: bold;\">if<\/span> choice <span style=\"color: #333333;\">==<\/span> <span style=\"background-color: #fff0f0;\">&#8216;7&#8217;<\/span>:<br \/>\nsys<span style=\"color: #333333;\">.<\/span>exit()<\/p>\n<p><span style=\"color: #008800; font-weight: bold;\">if<\/span> choice <span style=\"color: #333333;\">==<\/span> <span style=\"background-color: #fff0f0;\">&#8216;1&#8217;<\/span>:<br \/>\nAddBook()<\/p>\n<p><span style=\"color: #008800; font-weight: bold;\">elif<\/span> choice <span style=\"color: #333333;\">==<\/span> <span style=\"background-color: #fff0f0;\">&#8216;2&#8217;<\/span>:<br \/>\nDisplayBook()<\/p>\n<p><span style=\"color: #008800; font-weight: bold;\">elif<\/span> choice <span style=\"color: #333333;\">==<\/span> <span style=\"background-color: #fff0f0;\">&#8216;3&#8217;<\/span>:<br \/>\nDeleteBook()<\/p>\n<p><span style=\"color: #008800; font-weight: bold;\">elif<\/span> choice <span style=\"color: #333333;\">==<\/span> <span style=\"background-color: #fff0f0;\">&#8216;4&#8217;<\/span>:<br \/>\nViewBooks()<\/p>\n<p><span style=\"color: #008800; font-weight: bold;\">elif<\/span> choice <span style=\"color: #333333;\">==<\/span> <span style=\"background-color: #fff0f0;\">&#8216;5&#8217;<\/span>:<br \/>\nSearch()<\/p>\n<p><span style=\"color: #008800; font-weight: bold;\">elif<\/span> choice <span style=\"color: #333333;\">==<\/span> <span style=\"background-color: #fff0f0;\">&#8216;6&#8217;<\/span>:<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(GetTotal())<\/p>\n<p><span style=\"color: #008800; font-weight: bold;\">else<\/span>:<br \/>\n<span style=\"color: #008800; font-weight: bold;\">print<\/span>(<span style=\"background-color: #fff0f0;\">&#8220;Invalid input&#8221;<\/span>)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we would examine how to use Python to create an excel csv file, write data into it, read records from the file &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/207"}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":2,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"predecessor-version":[{"id":955,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/207\/revisions\/955"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}