How Python helps me write book reviews

How Python helps me write book reviews

Okay, I admit, the headline is a click-bait, which was supposed to get you here, but that's only half-true. If you are interested in how Python programming language can go hand in hand with reading books and extracting quotes from them, do stay with me.

As of recently, one of my hobbies is extracting parts of the books I read, into a short paragraphs or a simple one-line quotes. This is nothing new. Not more than two decades ago, while reading required school literature, I was underlining the quotes I liked. In some cases when the book was borrowed for example, I was rewriting quotes in my notebook.

No alt text provided for this image

Time and technology move forward, and now I do it in a slightly different form, by underlining directly in book reader.

No alt text provided for this image


Now, once I finish the book, I want to get all my notes "out" of the book reader, into my text file. Once I actually extract the notes, there will be many redundant lines, related to book itself and the author, in which I am not interested in. Below is an example of three quotes, which are followed by addtional info (this is added automatically when you highlight in book reader):

No alt text provided for this image

Naturally, I am interested only in the quotes themselves, not in this redundant information, which follows up. This is of course analogous to many areas of our lives: desired end result is often accompanied by a completelly unneeded by-products.

For the first few books, I was removing additional info manually, while listening to some music or documentary. Soon after however, activity like this starts to drive you crazy and what do you do? Automate it! And what do we use to automate stuff nowadays? You saw it comming - Python. If I can write a program to do something instead of me, you bet I am going to do so. Related to my primary job as a verification engineer, it is often desired to automate various aspects of my daily work and those who embrace this approach, will become significantly more effective in completing their tasks.

Back to my notes extracting problem. After a quick analyses, I saw that I need to write a program which will modify my text file by removing each line starting with "====", as well as the three subsequent lines. After that, in my text file there will only be quotes from the book (useful information I was interested in, in the first place).

Effective transformation of the text is shown below:

No alt text provided for this image


Below is the program I wrote:

No alt text provided for this image

Program itself is very simple, but that is besides the point. What is important here is the way of thinking and approach to solving the problem at hand. Whenever possible, we should try to automate borring and unneeded stuff in our daily activities. This particular example shows that we can use Python to automate stuff for us in real-life, not only in our day-to-day jobs. And I'm loving it.

In what way do you use Python to automate stuff?

要查看或添加评论,请登录

Milos Mirosavljevic的更多文章

  • SoC Verification VS Traditional (UVM) verification

    SoC Verification VS Traditional (UVM) verification

    "But why can't I just use our UVM testbench to verify SoC behavior?" I often hear junior engineers or those who have…

    33 条评论
  • PCIe vs. CXL vs. UCIe

    PCIe vs. CXL vs. UCIe

    Many years ago, my first project was related to PCIe Gen 3. Before that, I only encountered simple protocols UART…

    14 条评论
  • The Packaging of Microchips: 2D vs 2.5D vs 3D Integration

    The Packaging of Microchips: 2D vs 2.5D vs 3D Integration

    When we think about microchips, we often imagine tiny rectangles packed with billions of transistors. We imagine the…

  • SoC vs. Chiplets: What’s the Difference?

    SoC vs. Chiplets: What’s the Difference?

    In the world of hardware design, you’ve probably heard the terms System-on-Chip (SoC) and chiplets. Both are critical…

    21 条评论
  • Emulation vs. Prototyping: What’s the Difference?

    Emulation vs. Prototyping: What’s the Difference?

    If you work in hardware verification, you’ve probably heard about simulation, emulation, and prototyping. You probably…

    8 条评论
  • Debugging by Eliminating Potential Causes

    Debugging by Eliminating Potential Causes

    For verification engineers, the ability to quickly debug and diagnose test failures is an essential skill. My…

    3 条评论
  • Ever heard of AWK programming language?

    Ever heard of AWK programming language?

    I encountered awk for the first time many years ago while attempting to produce a script that would effectively search…

    6 条评论
  • Apply the 80/20 principle to efficiently learn SystemVerilog

    Apply the 80/20 principle to efficiently learn SystemVerilog

    I vividly remember my career start as a verification engineer: it was in late 2011, in the cold November (this reminds…

    6 条评论
  • Initiative - Hidden Gem In Your Skillset

    Initiative - Hidden Gem In Your Skillset

    Andrew, a young engineer, started his career like most others in his profession – eager to prove his worth and learn a…

    2 条评论
  • Power of Project Post-mortems

    Power of Project Post-mortems

    I am a big fan of the lessons-learned approach. It is, in fact, one of my principles in life (you guessed right - I…

    5 条评论

社区洞察

其他会员也浏览了