Evernote Scraper 4

Still working on the Evernote scraper. Recently I haven’t been working on it as much so the article will likely be very short. A simple tweak I did to the code was to print a new newline just before it printed a date value. This made the output of the loop much clearer and easier to read.

The main goal now is to turn this output into CSV file straight from the loop. I probably need to turn the values from the loop into variables. As these values in this printed form are only in the loop.

Trying to do this is turning to be very difficult because when appending the values to a new list, the previous issues occurred like values appearing as lists or values in the wrong order. If I make a new list it will need to have the values in the right order. With either two types of designs. A nested list where the values of the lift stored with an individual day. Or a flat list which the values stored in the correct order on after the other.

When appending some of these values to a new list I noticed that the list contain a few duplicate dates.

2 pic.png

I think the reason is that the regex matches the “pr” character. The regex for pr was used for the press values. But the regex also captures the month of April. So I trying to develop an exception to the characters of April. They are mainly to main way could do so. The first is using a look around a pattern or using a negated set.

Using the negated set seems to return some results.

3 pic.png

But when testing it out in the python program it does not make a difference. But I quickly found the solution I was tweaking the regex pattern. As I was using the individual regex pattern rather than the master regex pattern.

4 pic.png

So now we need to start designing how the CSV writer should function. Probably need to use a few if statements to regex to sort the values out to the different columns. Made a quick list for the header or first row.

header = ["Date", "Squat", "Press", "Deadlift"", Bench", "Power clean", "notes"]

Then added this for the CSV writer lifts_writer.writerow(header).

Which should create the first row.

As the CSV writer writes in rows, not columns. I will need to find a way I could write all values all in one row. To do this I will probably need to zip the values or turn to mini lists. Within the CSV open I'm using a loop and if statements.

values_to_row = []
    for values in value_to_list:
        if regex_dates.search(values):
                values_to_row.append(values)

The loop is to cycle through values in the list and the if statements to append to the temporary list used to write rows into the CSV file. The current issue is that values will need to be cleared out for every individual day.

Tobi Olabode