insanum / gcalcli

Google Calendar Command Line Interface
MIT License
3.26k stars 308 forks source link

Enhancement: import agenda from CSV #550

Open michaelmhoffman opened 3 years ago

michaelmhoffman commented 3 years ago

I often need to do bulk editing of my calendar which is not super convenient with the Google Calendar web interface. A spreadsheet interface would be much better.

What would you think about a way to do roundtrip updates through gcalcli agenda --tsv and a paired command agendaupdate for writing any changes back? We would need:

Future extensions or subsequent refactoring could include:

michaelmhoffman commented 3 years ago

@jcrowgey Could you let me know what you think of this design?

jcrowgey commented 3 years ago

Overall this looks good to me. Your recent work on this project has been very helpful and appreciated. I'm sorry for the long delays. In general, I'm not going to be able to work on gcalcli much for the foreseeable future.

On Mon, Jul 27, 2020 at 03:15:57PM -0700, Michael Hoffman wrote:

@jcrowgey Could you let me know what you think of this design?

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/insanum/gcalcli/issues/550#issuecomment-664665671

michaelmhoffman commented 3 years ago

To get the TSV output of gcalcli agenda to work automatically in Microsoft Excel with non-ASCII characters, it is necessary to set PYTHONIOENCODING=utf_16. Things that don't work utf_16_le (no BOM) or utf_8_sig (BOM but for whatever reason Excel ignores the tabs by default). This does not seem like a sensible default but if you intend to use these files with Excel you should know about it.

michaelmhoffman commented 3 years ago

The easiest way to use a UTF-16 file.tsv is to use input redirection with the PYTHONIOENCODING environment variable set. There's no user-accessible way to change the encoding of what's read with a file argument.

PYTHONIOENCODING=utf_16 gcalcli agendaupdate < file.tsv
michaelmhoffman commented 3 years ago

The output of PYTHONIOENCODING=utf_16 gcalcli agenda isn't easy to use some other Unix tools like grep with. Instead you can use iconv --to-code=utf-16 as part of a pipeline. For example:

gcalcli agenda | grep Title | iconv --to-code=utf-16 > file.csv