# Read dump

URL: https://docs.emergingtravel.com/docs/how-tos/process-dump/read-dump/

Tags: how-tos

---


> [!WARNING]
> As the decompressed dump size can exceed 20 GB:
> * You have to read the dump line by line.
> * It might take a while.




**Node.js**

```js {linenos=inline}
import fs from 'fs';

let stream = fs.createReadStream(newFileName, { flags: 'r', encoding: 'utf-8' });
let buffer = '';
let hotel;

// line is the current processed line
async function processLine(line) {
  if (line[line.length - 1] == '\r') {
    line = line.substr(0, line.length - 1);
  }
  if (line.length > 0) {
    hotel = JSON.parse(line);
    // TODO: your logic
  }
}

async function readLineByLine() {
  let position;
  while ((position = buffer.indexOf('\n')) >= 0) {
    if (position == 0) {
      buffer = buffer.slice(1);
      continue;
    }
    await processLine(buffer.slice(0, position));
    buffer = buffer.slice(position + 1);
  }
}

async function readDump() {
  stream.on('data', function (functionData) {
    buffer += functionData.toString();
    readLineByLine();
  });
}

await readDump();
```

**Python**

```python {linenos=inline}
# decompressed_file_name is the decompressed dump file name
def read_dump(decompressed_file_name):
    with open(decompressed_file_name, "r") as f:
        s = f.readline()
        while s:
            hotel = json.loads(s)
            # TODO: your logic
            s = f.readline()


if __name__ == "__main__":
    read_dump(decompressed_dump_name)
```



