kiwiz / gkeepapi

An unofficial client for the Google Keep API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Notes are created out of order

yuvgin opened this issue · comments

I'm using gkeepapi to transfer notes into keep from another note app.

I have a dataframe of ~1000 notes that I iterate over. The dataframe is sorted by creation date (of the original notes) but when I sync they appear in keep in the wrong order (despite the fact that the node's timestamps are in the correct order).
Any idea what's going on?

Running on Ubuntu with python 3.7

commented

I believe there are two issues here:

  • Timestamps (IIRC) are not honored - the value is set by the server when a new note is synced
  • There is no guarantee of order when more than one node is synced to the server

For the behaviour you desire, you might have to call sync() after every new note.

Thanks for the quick reply.
I tried syncing after every createNote, and also tried adding time.sleep after every sync. Didn't do the trick..

commented

Oh, I understand now. The sorting of notes is defined via the sort attribute on notes, which is randomly generated. You can set it to a monotonically increasing/decreasing value:

for i, blah in enumerate(items):
    note = keep.createNote()
    note.sort = i
    ...

That works, thanks!!
Perhaps add it to the docs, it seems important :)