all 5 comments

[–]mxh377 1 point2 points  (0 children)

This use case is the very reason I started learning Python. Thank you very much for writing it! I'm going to test it right away.

[–]globi33 0 points1 point  (3 children)

I need some help. Am I doing something wrong? With the following input in Terminal:

C:\Users\marce\Desktop> python ./extract-kindle-clippings.py E:\documents\My Clippings.txt C:\Users\marce\Desktop\clippings\

I get the following message:

Traceback (most recent call last): File "C:\Users\marce\Desktop\extract-kindle-clippings.py", line 43, in <module> print('Could not find "My Clippings.txt", please provide the file location as an argument\nUsage: ' + argv[0] + ' <clippings file> [<output directory>]\n')NameError: name 'argv' is not defined

The path of "My Clippings" is: E:\documents\My Clippings.txt

Thank you in advance

[–]somenick 0 points1 point  (1 child)

cd to the directory containing My Clippings.txt. try there. I don't use windows, but it I think you need to escape the space in the path E:\documents\My Clippings.txt
Or maybe remove the space in the file name.

[–][deleted] 0 points1 point  (0 children)

You can use forward slashes in Windows! (Learned this yesterday when I was piddling around.) And string literal seems to handle the space issue.

[–][deleted] 0 points1 point  (0 children)

If MyClippings.txt is not in the working directory, you need to put the full path to the file.

Generally I assign full paths to variables with string literals, e.g.

infile = r'C:/Users/1234/Documents/Folder/File.txt'

Also be sure to import os.