<commit_before># Import Database of Beers in OrientDB

First, create a new folder somewhere in your hard drive. For this test I've used /temp/openbeer.

```
$ mkdir /temp/openbeer
```

## Download Beers Database in CSV format

```
$ curl http://openbeerdb.com/data_files/openbeerdb_csv.zip > openbeerdb_csv.zip
$ unzip openbeerdb_csv.zip
```

## Install OrientDB

```
$ curl "http://orientdb.com/download.php?email=<EMAIL>&file=orientdb-community-2.0.7.zip&os=multi" > orientdb-community-2.0.7.zip
$ unzip orientdb-community-2.0.7.zip
```


## Import Beer Categories

These are the first 2 lines of `categories.csv` file:
```
"id","cat_name","last_mod"
"1","British Ale","2010-10-24 13:50:10"
```

In order to import this file in OrientDB, we have to create the following file as `categories.json`:

```json
{
  "source": { "file": { "path": "/temp/openbeer/openbeerdb_csv/categories.csv" } },
  "extractor": { "row": {} },
  "transformers": [
    { "csv": {} },
    { "vertex": { "class": "Category" } }
  ],
  "loader": {
    "orientdb": {
       "dbURL": "plocal:../databases/openbeerdb",
       "dbType": "graph",
       "classes": [
         {"name": "Category", "extends": "V"}
       ], "indexes": [
         {"class":"Category", "fields":["id:integer"], "type":"UNIQUE" }
       ]
    }
  }
}
```

Now to import it OrientDB, move into the "bin" directory of OrientDB distribution.

```
$ cd orientdb-community-2.0.7/bin
```

And run OrientDB ETL.

```
$ ./oetl.sh /temp/openbeer/categories.json

OrientDB etl v.2.0.7 (build @BUILD@) www.orientechnologies.com
BEGIN ETL PROCESSOR
END ETL PROCESSOR
+ extracted 12 rows (0 rows/sec) - 12 rows -> loaded 11 vertices (0 vertices/sec) Total time: 77ms [0 warnings, 0 errors]
```


## Import Beer Styles
Now it's the turn of Beer Styles. These are the first 2 lines of the `styles.csv` file.

```
"id","cat_id","style_name","last_mod"
"1","1","Classic English-Style Pale Ale","2010-10-24 13:53:31"
```

In this case we'll correlate the Style with the Category created earlier. This is the `styles.json` to use with OrientDB ETL for the next step.

```json
{
  "source": { "file": { "path": "/temp/openbeer/openbeerdb_csv/styles.csv" } },
  "extractor": { "row": {} },
  "transformers": [
    { "csv": {} },
    { "vertex": { "class": "Style" } },
    { "edge": { "class": "HasCategory",  "joinFieldName": "cat_id", "lookup": "Category.id" } }
  ],
  "loader": {
    "orientdb": {
       "dbURL": "plocal:../databases/openbeerdb",
       "dbType": "graph",
       "classes": [
         {"name": "Style", "extends": "V"},
         {"name": "HasCategory", "extends": "E"}
       ], "indexes": [
         {"class":"Style", "fields":["id:integer"], "type":"UNIQUE" }
       ]
    }
  }
}
```
$ ./oetl.sh /temp/openbeer/styles.json

OrientDB etl v.2.0.7 (build @BUILD@) www.orientechnologies.com
BEGIN ETL PROCESSOR
END ETL PROCESSOR
+ extracted 142 rows (0 rows/sec) - 142 rows -> loaded 141 vertices (0 vertices/sec) Total time: 498ms [0 warnings, 0 errors]
```


## Import Breweries
Now it's the turn of Breweries. These are the first 2 lines of the `breweries.csv` file.

```
"id","name","address1","address2","city","state","code","country","phone","website","filepath","descript","last_mod"
"1","(512) Brewing Company","407 Radam, F200",,"Austin","Texas","78745","United States","512.707.2337","http://512brewing.com/",,"(512) Brewing Company is a microbrewery located in the heart of Austin that brews for the community using as many local, domestic and organic ingredients as possible.","2010-07-22 20:00:20"
```

Breweries have no outgoing relations with other entities, so this is a plain import similar to categories. This is the `breweries.json` to use with OrientDB ETL for the next step.

```json
{<commit_msg>Updated Import the Database of Beers (markdown)<commit_after># Import Database of Beers in OrientDB

First, create a new folder somewhere in your hard drive. For this test I've used /temp/openbeer.

```
$ mkdir /temp/openbeer
```

## Download Beers Database in CSV format

```
$ curl http://openbeerdb.com/data_files/openbeerdb_csv.zip > openbeerdb_csv.zip
$ unzip openbeerdb_csv.zip
```

## Install OrientDB

```
$ curl "http://orientdb.com/download.php?email=<EMAIL>&file=orientdb-community-2.0.7.zip&os=multi" > orientdb-community-2.0.7.zip
$ unzip orientdb-community-2.0.7.zip
```


## Import Beer Categories

These are the first 2 lines of `categories.csv` file:

```
"id","cat_name","last_mod"
"1","British Ale","2010-10-24 13:50:10"
```

In order to import this file in OrientDB, we have to create the following file as `categories.json`:

```json
{
  "source": { "file": { "path": "/temp/openbeer/openbeerdb_csv/categories.csv" } },
  "extractor": { "row": {} },
  "transformers": [
    { "csv": {} },
    { "vertex": { "class": "Category" } }
  ],
  "loader": {
    "orientdb": {
       "dbURL": "plocal:../databases/openbeerdb",
       "dbType": "graph",
       "classes": [
         {"name": "Category", "extends": "V"}
       ], "indexes": [
         {"class":"Category", "fields":["id:integer"], "type":"UNIQUE" }
       ]
    }
  }
}
```

Now to import it OrientDB, move into the "bin" directory of OrientDB distribution.

```
$ cd orientdb-community-2.0.7/bin
```

And run OrientDB ETL.

```
$ ./oetl.sh /temp/openbeer/categories.json

OrientDB etl v.2.0.7 (build @BUILD@) www.orientechnologies.com
BEGIN ETL PROCESSOR
END ETL PROCESSOR
+ extracted 12 rows (0 rows/sec) - 12 rows -> loaded 11 vertices (0 vertices/sec) Total time: 77ms [0 warnings, 0 errors]
```


## Import Beer Styles
Now it's the turn of Beer Styles. These are the first 2 lines of the `styles.csv` file.

```
"id","cat_id","style_name","last_mod"
"1","1","Classic English-Style Pale Ale","2010-10-24 13:53:31"
```

In this case we'll correlate the Style with the Category created earlier. This is the `styles.json` to use with OrientDB ETL for the next step.

```json
{
  "source": { "file": { "path": "/temp/openbeer/openbeerdb_csv/styles.csv" } },
  "extractor": { "row": {} },
  "transformers": [
    { "csv": {} },
    { "vertex": { "class": "Style" } },
    { "edge": { "class": "HasCategory",  "joinFieldName": "cat_id", "lookup": "Category.id" } }
  ],
  "loader": {
    "orientdb": {
       "dbURL": "plocal:../databases/openbeerdb",
       "dbType": "graph",
       "classes": [
         {"name": "Style", "extends": "V"},
         {"name": "HasCategory", "extends": "E"}
       ], "indexes": [
         {"class":"Style", "fields":["id:integer"], "type":"UNIQUE" }
       ]
    }
  }
}
```

Now import the styles.

```
$ ./oetl.sh /temp/openbeer/styles.json

OrientDB etl v.2.0.7 (build @BUILD@) www.orientechnologies.com
BEGIN ETL PROCESSOR
END ETL PROCESSOR
+ extracted 142 rows (0 rows/sec) - 142 rows -> loaded 141 vertices (0 vertices/sec) Total time: 498ms [0 warnings, 0 errors]
```


## Import Breweries
Now it's the turn of Breweries. These are the first 2 lines of the `breweries.csv` file.

```
"id","name","address1","address2","city","state","code","country","phone","website","filepath","descript","last_mod"
"1","(512) Brewing Company","407 Radam, F200",,"Austin","Texas","78745","United States","512.707.2337","http://512brewing.com/",,"(512) Brewing Company is a microbrewery located in the heart of Austin that brews for the community using as many local, domestic and organic ingredients as possible.","2010-07-22 20:00:20"
```

Breweries have no outgoing relations with other entities, so this is a plain import similar to categories. This is the `breweries.json` to use with OrientDB ETL for the next step.

```json
{
{'fraction_non_alphanumeric': 0.1810049986845567, 'fraction_numerical': 0.033412259931596945, 'mean_word_length': 3.818124207858048, 'pattern_counts': {'":': 92, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3373428', 'n_tokens_mistral': 2861, 'n_tokens_neox': 2591, 'n_words': 730}