<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shahil</title>
    <description>The latest articles on DEV Community by Shahil (@shahilv).</description>
    <link>https://dev.to/shahilv</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2391486%2F2b0d5ae9-cf56-426a-9219-fc891e6756c9.jpg</url>
      <title>DEV Community: Shahil</title>
      <link>https://dev.to/shahilv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shahilv"/>
    <language>en</language>
    <item>
      <title>How to Export Your Omnivore Data to CSV Using Bash &amp; jq</title>
      <dc:creator>Shahil</dc:creator>
      <pubDate>Sat, 09 Nov 2024 11:57:45 +0000</pubDate>
      <link>https://dev.to/shahilv/how-to-export-your-omnivore-data-to-csv-using-bash-jq-13j2</link>
      <guid>https://dev.to/shahilv/how-to-export-your-omnivore-data-to-csv-using-bash-jq-13j2</guid>
      <description>&lt;p&gt;Omnivore has recently announced their shutdown, as such users have limited time to export our data! They have provided a short guide on exporting and converting your data to csv (&lt;a href="https://docs.omnivore.app/using/exporting.html" rel="noopener noreferrer"&gt;https://docs.omnivore.app/using/exporting.html&lt;/a&gt;). Though unfortunately the label option did not work for me. Now, since Omnivore provides an export option in JSON format, we can use the &lt;code&gt;jq&lt;/code&gt; tool they mention to convert this data into a structured CSV, making it easier to import into other tools.&lt;/p&gt;

&lt;p&gt;Disclaimer - This article was written with the help of AI in terms of command explanations and after some experimenting with &lt;code&gt;jq&lt;/code&gt;, the solution command was also finally achieved with ChatGPT.&lt;/p&gt;

&lt;p&gt;I’ll walk you through converting Omnivore’s JSON export to a CSV format using &lt;code&gt;jq&lt;/code&gt;, a powerful command-line JSON processor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;jq&lt;/strong&gt;: A command-line JSON processor. If you don’t have it installed, you can download it &lt;a href="https://stedolan.github.io/jq/download/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bash terminal&lt;/strong&gt;: This can be found on most Unix-based systems or via Git Bash on Windows.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Export Your Data from Omnivore
&lt;/h2&gt;

&lt;p&gt;Head to Omnivore's export tool and download your data in JSON format. These files will typically contain all your saved links, notes, and any tags associated with each item.&lt;/p&gt;

&lt;p&gt;Save these JSON files in a folder where you’ll be working, as we’ll use &lt;code&gt;jq&lt;/code&gt; to parse it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Set Up the jq Command to Convert JSON to CSV
&lt;/h2&gt;

&lt;p&gt;Omnivore exports data in JSON format as one of it's options, but to import your bookmarks into a service like Raindrop.io - which is what I have chosen next, we need a headed CSV file. Here’s how to set up &lt;code&gt;jq&lt;/code&gt; to format Omnivore’s JSON data to match a CSV structure.&lt;/p&gt;

&lt;p&gt;Omnivore JSON typically has fields like &lt;code&gt;url&lt;/code&gt;, &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;labels&lt;/code&gt; (tags), and &lt;code&gt;savedAt&lt;/code&gt;. We’ll extract these fields and add a header row for the CSV format.&lt;/p&gt;

&lt;h3&gt;
  
  
  Run This Command
&lt;/h3&gt;

&lt;p&gt;Note that on windows, I moved the jq.exe file to C:\Program Files\Git\usr\bin and added it to my PATH environment system variables for Bash to recognise the command.&lt;/p&gt;

&lt;p&gt;In your terminal, navigate to the folder containing the JSON file and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'["url", "title", "tags", "created"], (.[] | [.url, .title, (.labels | join(", ")), .savedAt]) | @csv'&lt;/span&gt; &lt;span class="k"&gt;*&lt;/span&gt;.json &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; omnivore_data.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Command Breakdown:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Headers&lt;/strong&gt;: &lt;code&gt;["url", "title", "tags", "created"]&lt;/code&gt; defines the headers of the CSV file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Extraction&lt;/strong&gt;: &lt;code&gt;(.[] | [.url, .title, (.labels | join(", ")), .savedAt])&lt;/code&gt; extracts each bookmark's &lt;code&gt;url&lt;/code&gt;, &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;labels&lt;/code&gt; (joined with commas for multiple tags), and &lt;code&gt;savedAt&lt;/code&gt; date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/csv"&gt;@csv&lt;/a&gt;&lt;/strong&gt;: Converts the extracted data to CSV format, handling necessary quotes for fields with spaces or commas.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This command will output a CSV file named &lt;code&gt;omnivore_data.csv&lt;/code&gt; with your data neatly formatted. You may adjust the command accordingly if you need the other fields.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example Output:
&lt;/h3&gt;

&lt;p&gt;The CSV file will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;url,title,tags,created
https://mantine.dev,"Mantine","react, UI","2024-08-04T22:32:24.347Z"
https://developer.mozilla.org,"MDN Web Docs","documentation, reference","2024-08-10T12:15:30.234Z"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each line represents a bookmark entry with the following columns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;url&lt;/strong&gt;: The link’s URL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;title&lt;/strong&gt;: The title of the saved page.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tags&lt;/strong&gt;: Comma-separated tags for each link.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;created&lt;/strong&gt;: The date the link was saved (in ISO 8601 format).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy bookmarking!&lt;/p&gt;

</description>
      <category>omnivore</category>
      <category>bookmarks</category>
    </item>
  </channel>
</rss>
