omnivore-app / omnivore

Omnivore is a complete, open source read-it-later solution for people who like reading.
https://omnivore.app
GNU Affero General Public License v3.0
13.91k stars 983 forks source link

Sharing your after-exporting JQ command here #4493

Open Gitbreast opened 2 weeks ago

Gitbreast commented 2 weeks ago

You can share your jq command used after exporting here. I think pasting all the jq command to one issue is better for searching, for some newbies like me. I run the jq command below in Unix shell (macOS, etc) and it works, inspired by @ocean https://github.com/omnivore-app/omnivore/issues/4461#issuecomment-2453673588. But I cannot make this jq works in Windows. If you've done it, come on and share it here for others. How to export: https://docs.omnivore.app/using/exporting.html Below is the original post.


This is a jq command with a little fine-tune for converting to.xlsx format and .md format, and I add links to local files by =HYPERLINK() command.

Tips: The jq command can directly run in Unix shell such like macOS terminal, but it cannot directly work in windows cause the “quote problem”. You can fine-tune it and give it a try, check: https://jqlang.github.io/jq/manual/

Follow these steps to .xlsx (in macOS):

  1. Follow these official steps. Download your Omnivore ZIP. Unzip it.
  2. Enter the folder, right click the folder name on the bottom bar, choose “open in terminal”.
  3. Paste these code in the terminal and press enter.
    jq -r '
    (["Tags","Title","Description","Created","File","URL"]), 
    (.[] | [
    ([.labels[]?]|join(",")),
    (.title | gsub("\\n";" ") | gsub("\\r";" ") | gsub("\"";"''") | gsub("[^[:print:]]";" ") | gsub("\\s+";" ")),
    (.description | gsub("\\n";" ") | gsub("\\r";" ") | gsub("\"";"''") | gsub("[^[:print:]]";" ") | gsub("\\s+";" ")),
    .savedAt,
    ("=HYPERLINK(G1&\"\\content\\" + .slug + ".html\" ,\"Open\")"),
    .url
    ]) | @csv
    ' metadata_*.json > omnivore-export.csv
  4. You should see the omnivore-export.csv file appears in the same folder. Open it with Numbers App.
  5. In Numbers’s menu, click "Files > Export As > Excel…" , next step, export.
  6. You should see the omnivore-export.xlsx file appears in the same folder.
  7. Transport the folder to a windows PC. Open the .xlsx with Excel.
  8. Copy the folder path in windows, and paste it to the G2 cell in Excel.
  9. Now click a random "Open" button in column E, you should open a local html file.

PS. I cannot make the links in .xlsx work in macOS, but they work in windows, you can give it a try.

Eventually, it looks like this, I covered the text, notice G2 and column E:

image

And here’s a version for Markdown .md. Get the .csv file and drop it to an online converter like this. Markdown softwares are slow at so much data though.

jq -r '
  (["Tags","Title","Description","Created","File","URL"]), 
  (.[] | [
    ([.labels[]?]|join(",")),
    (.title | gsub("\\n";" ") | gsub("\\r";" ") | gsub("\"";"''") | gsub("[^[:print:]]";" ") | gsub("\\s+";" ")),
    (.description | gsub("\\n";" ") | gsub("\\r";" ") | gsub("\"";"''") | gsub("[^[:print:]]";" ") | gsub("\\s+";" ")),
    .savedAt,
    ("[Open](.\\content\\" + .slug + ".html)"),
    .url
  ]) | @csv
' metadata_*.json > omnivore-export.csv