# Converting Instagram saved\_collections.json file to csv file and importing it t

![](https://i.imgur.com/bkSWKjm.png)

## Download Your Instagram Data from the Account Deletion Interface

> 💡 You will not be deleting your account, you will only proceed to the download my data section

[Help Center](https://help.instagram.com/181231772500920?cms_id=181231772500920)

## Then, extract the `saved_collections.json` file from the downloaded `zip`

* This file keeps your saved `collections` contents along with your tags
* We will continue our operations with this file

## Converting `saved_collections.json` file to `csv`

* Requires `nodejs` installation
* Run the javascript code below in the directory of `saved_collections.json`
* Or give the file path to the bottom line of the code

```javascript
const { readFileSync, writeFileSync } = require("fs")

function jsonToCSV(json) {
	const csvRows = []
	csvRows.push("Name,Time,URL,Channel,Tags")

	for (const [key, value] of Object.entries(json)) {
		const tags = value.tags.join(",")
		const utcTime = value.time.toISOString()
		csvRows.push(`${value.name},${utcTime},${key},${value.channel},"${tags}"`)
	}

	return csvRows.join("\\n")
}

function instagramCollectionToCSV(inputPath) {
	const content = JSON.parse(readFileSync(inputPath))

	const data = {}
	let tag = undefined
	content.saved_saved_collections.forEach(collection => {
		const url = collection.string_map_data.Name.href
		if (url === undefined) {
			const rawTag = collection.string_map_data.Name.value
			tag = Buffer.from(rawTag, "binary").toString("utf8")
			return
		}

		const name = url.split("/").slice(-2)[0]
		const time = new Date(collection.string_map_data["Added Time"].timestamp * 1000)
		const channel = collection.string_map_data.Name.value

		if (!data[url]) {
			data[url] = { channel, tags: [], time, name }
		}
		if (tag && !data[url].tags.includes(tag)) {
			data[url].tags.push(tag)
		}
	})

	const csv = jsonToCSV(data)
	const outputPath = path.replace(".json", ".csv")
	writeFileSync(outputPath, csv)
}

const path = "./saved_collections.json"
instagramCollectionToCSV(path)


```

## Importing the `csv` file onto Notion

<details>

<summary>Use the `import - csv` interface</summary>

<img src="https://i.imgur.com/znLUGo5.png" alt="" data-size="original">

</details>

## Formatting Notion data

<details>

<summary>Keep `channel` data as `select`</summary>

<img src="https://i.imgur.com/CM4Nbjz.png" alt="" data-size="original">

</details>

<details>

<summary>Store `Tags` part as `multi select`</summary>

\- The \`csv\` file is prepared to be suitable for automatic formatting - As soon as you do \`multi select\`, your \`tags\` values will match

<img src="https://i.imgur.com/0CGhBZo.png" alt="" data-size="original">

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yemreak.com/arsiv/programming/converting-instagram-saved_collectionsjson-file-to-csv-file-and-importing-it-to-notion.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
