Evernote scraper 5

The main focus is to turn the data from the list to the csv. Using the csv writer to make the csv file of the files. My first idea is to create a short list which will store the values day. To be then used to write the row with the csv file. Then clearing the list for the next batch of data for the next row. When I wrote up the code to do use there was an issue where only one value counted in the row.

This is the code typed up

lifts_writer.writerow(values_to_row)
        print(values_to_row)
        values_to_row.clear()

This piece of code lies below the elif statements and the list is defined outside of the loop.

An improvement I found is that I can added a another if statement to stated the value_to_row list has more than three items before writing to csv and clearing.

if len(values_to_row) > 3:
            lifts_writer.writerow(values_to_row)
            values_to_row.clear()

As row will likely have around 3-4 items, mainly date and three other lifts.

2pic.png

Another error popped up, were writing the csv file the commard line returned this: UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f613' in position 81: character maps to <undefined>

In the beginning I was very stumbled, as I tried solutions like converting the sting code into the character and creating more if statements. But luckily the solution is more simple. When creating the csv writer I forget to put the enoding option in the open statement. So I simply added it,

with open('lifts.csv', mode='w', encoding='utf-8') as lifts_file:

Then problem was solved.

The next problem is a duplicate of a previous problem. Some of the values did not start with the data first making the following values incorrect because of the wrong orders.

Make makes this problem slightly different is that slicing the list is a bit harder. And making nested list via that method will make writing the csv file more difficult. The writing of the rows is done by count the amount of items in the list, which is a bit different via slicing the list.

Tobi Olabode