[PYTHON] [Simplified version] How to export the minimum reading meter recording information

Introduction

First of all, *** Reading meter information cannot be exported ***. It's clogged. thank you for your hard work.

However, the purpose of export *** is to extract past information ***, so it's okay if you can forcibly extract it for the time being. It feels like a pseudo-export (I'm not doing such a big deal).

I used to use a reading meter, but I thought it wasn't very convenient to use. I decided, "Better yet, let's manage and record readings with spreadsheets! ***".

The information I wanted *** was about the reading date, title, and author name of the book I read (+ α number of pages). I didn't write all my impressions, and I thought I wouldn't manage them in a spreadsheet, so I didn't need them (I wonder if I can record my impressions in a notebook or write them in a book keyword). Web scraping is also dull, and I feel like there is an easy way.

*** There was an easy way. *** ***

Completion drawing

I was able to transfer the reading meter records to a spreadsheet ~.

image.png

Necessary items

--Environment: Python 3.7.4 --Reading meter information --Reading date --Title --Author name

Preparation: Obtaining information on the reading meter

1. 1. Select "Read book"-> "Text only" and copy as it is.

This was a surprisingly blind spot. I had never used the "text only" function, but I thought "it's really usable!" *** The biggest point of this article ***. The rest is a copy. Easy victory. I think you can boil or bake with your creativity. image.png image.png

2. Paste everything in Excel

image.png

3. 3. Add or fix missing information

Sometimes there is one without information (image below). Sometimes the title and author name are in the same cell. Please correct as appropriate. I fixed it while running the program. That may be easier to understand.

image.png

4. Save Excel as CSV

For the time being, name it ʻinput.csv`.

Run the program

I wrote it with brain death while watching the animation. I made it for myself so it's shit dirty. Please forgive me because it was a throw-away program that ended once I wrote it.

main.py


import csv
import pandas as pd

RESULT_CSV_TITLE = 'output.csv'

date_list = []
title_person_list = []
page_list = []

df = pd.DataFrame()

with open('input.csv', mode='r', encoding='utf-8') as f:
    all_row = csv.reader(f)

    for row in all_row:

        #Remove whitespace and extra columns
        if len(row) == 0 or row[0] == 'To edit':
            continue

        #date
        try:
            if 'Unknown date' in row[0] :
                date_list.append(row[0])
                continue
            date_split = row[0].split('/')

            year = date_split[0]
            month = date_split[1]
            day = date_split[2]

            date_list.append(f'{year}/{month}/{day}')
            continue
        except:
            pass

        #page
        try:
            page = int(row[0])
            page_list.append(page)
            continue
        except:
            pass

        #List of titles and authors
        title_person_list.append(row[0])


    title_list = title_person_list[::2]
    person_list = title_person_list[::-2]
    # print(len(date_list))
    # print(len(page_list))
    # print(len(title_list))
    # print(len(person_list))

    person_list.reverse()

    df['date'] = date_list
    df['title'] = title_list
    df['Author'] = person_list
    df['page'] = page_list

    print(df)
    df.to_csv(RESULT_CSV_TITLE, index=False)

result

Since I am looking at the result using PyCharm, it looks like the image shown below. It feels like the date, title, author name, and number of pages. image.png

After that, please boil or bake. I copied all the contents of ʻoutput.csv` into a spreadsheet and separated them with commas. image.png

Finally

*** If you don't understand anything about the program, please contact the DM at @yuki_imamura_ ***. I hope I can help you.

No, I've used a lot of reading management and recording apps, but they're all subtle. After all, it's better to manage it yourself with Google Spreadsheets.

I think that you can extract reading impressions by using web scraping (I have not seen the terms of service), but this time I did not need it, so I did it easily. If there is a person who absolutely needs it, I will make a program, so please skip it as well.

The number of pages is ... I wonder if I can use it as a motivation index.

So let's enjoy reading life to the fullest!

I hope it will be helpful for you.

References

-Reading Meter: Record the books you read and meet new ones -Google Spreadsheets Comma Separated Tips

Recommended Posts

[Simplified version] How to export the minimum reading meter recording information
How to get the Python version
How to check the Java version used by Maven
How to run the Export function of GCP Datastore automatically
How to use the generator
Tabpy 1.0 (2020-01 version) How to install
How to change Python version
How to use the decorator
How to increase the axis
How to start the program
The first artificial intelligence. How to check the version of Tensorflow installed.
How to update the python version of Cloud Shell on GCP
How to set up the development environment of ev3dev [Windows version]
[Beginner memo] How to specify the library reading path in Python
How to use the zip function
How to use the optparse module
How to read the SNLI dataset
[Python] How to import the library
The minimum Cement information you need
How to overwrite the output to the console
How to check Linux OS version
How to use the ConfigParser module
How to study for the Deep Learning Association G test (for beginners) [2020 version]