File size: 3,918 Bytes
acc4ffe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1f3a5ebf",
   "metadata": {},
   "source": [
    "# Airbyte JSON\n",
    "This covers how to load any source from Airbyte into a local JSON file that can be read in as a document\n",
    "\n",
    "Prereqs:\n",
    "Have docker desktop installed\n",
    "\n",
    "Steps:\n",
    "\n",
    "1) Clone Airbyte from GitHub - `git clone https://github.com/airbytehq/airbyte.git`\n",
    "\n",
    "2) Switch into Airbyte directory - `cd airbyte`\n",
    "\n",
    "3) Start Airbyte - `docker compose up`\n",
    "\n",
    "4) In your browser, just visit http://localhost:8000. You will be asked for a username and password. By default, that's username `airbyte` and password `password`.\n",
    "\n",
    "5) Setup any source you wish.\n",
    "\n",
    "6) Set destination as Local JSON, with specified destination path - lets say `/json_data`. Set up manual sync.\n",
    "\n",
    "7) Run the connection!\n",
    "\n",
    "7) To see what files are create, you can navigate to: `file:///tmp/airbyte_local`\n",
    "\n",
    "8) Find your data and copy path. That path should be saved in the file variable below. It should start with `/tmp/airbyte_local`\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "180c8b74",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.document_loaders import AirbyteJSONLoader"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4af10665",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_airbyte_raw_pokemon.jsonl\r\n"
     ]
    }
   ],
   "source": [
    "!ls /tmp/airbyte_local/json_data/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "721d9316",
   "metadata": {},
   "outputs": [],
   "source": [
    "loader = AirbyteJSONLoader('/tmp/airbyte_local/json_data/_airbyte_raw_pokemon.jsonl')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9858b946",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = loader.load()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "fca024cb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "abilities: \n",
      "ability: \n",
      "name: blaze\n",
      "url: https://pokeapi.co/api/v2/ability/66/\n",
      "\n",
      "is_hidden: False\n",
      "slot: 1\n",
      "\n",
      "\n",
      "ability: \n",
      "name: solar-power\n",
      "url: https://pokeapi.co/api/v2/ability/94/\n",
      "\n",
      "is_hidden: True\n",
      "slot: 3\n",
      "\n",
      "base_experience: 267\n",
      "forms: \n",
      "name: charizard\n",
      "url: https://pokeapi.co/api/v2/pokemon-form/6/\n",
      "\n",
      "game_indices: \n",
      "game_index: 180\n",
      "version: \n",
      "name: red\n",
      "url: https://pokeapi.co/api/v2/version/1/\n",
      "\n",
      "\n",
      "\n",
      "game_index: 180\n",
      "version: \n",
      "name: blue\n",
      "url: https://pokeapi.co/api/v2/version/2/\n",
      "\n",
      "\n",
      "\n",
      "game_index: 180\n",
      "version: \n",
      "n\n"
     ]
    }
   ],
   "source": [
    "print(data[0].page_content[:500])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fa002a5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}