如何从Parquet文件导入表数据到Memgraph图数据库

huangapple go评论53阅读模式
英文:

How to import table data from Parquet file to Memgraph graph database

问题

我正在处理一个项目,需要将Parquet文件中的表格数据导入到Memgraph图数据库中。我的数据看起来像这样:

+-----------+-------------+---------+------------+--------+
| FirstName | LastName    | Country | Occupation | Salary |
+-----------+-------------+---------+------------+--------+
| John      | Doe         | USA     | Engineer   | 70000  |
| Jane      | Smith       | UK      | Doctor     | 80000  |
| Max       | Johnson     | Canada  | Teacher    | 60000  |
| Emily     | Davis       | Germany | Scientist  | 90000  |
| Luke      | Rodriguez   | France  | Artist     | 50000  |
+-----------+-------------+---------+------------+--------+

我知道我可以将其转换为CSV,然后使用LOAD CSV Cypher子句,但这不太方便。我该怎么办?

英文:

I'm working on a project where I need to import table data from a Parquet file into the Memgraph graph database. My data looks something like this:

+-----------+-------------+---------+------------+--------+
| FirstName | LastName    | Country | Occupation | Salary |
+-----------+-------------+---------+------------+--------+
| John      | Doe         | USA     | Engineer   | 70000  |
| Jane      | Smith       | UK      | Doctor     | 80000  |
| Max       | Johnson     | Canada  | Teacher    | 60000  |
| Emily     | Davis       | Germany | Scientist  | 90000  |
| Luke      | Rodriguez   | France  | Artist     | 50000  |
+-----------+-------------+---------+------------+--------+

I know that I could convert this to CSV and then use LOAD CSV Cypher clause but this is inconvenient. What can I do?

答案1

得分: 1

Memgraph支持通过PyArrow包使用Parquet文件格式。要将Parquet文件中的数据导入到Memgraph中,您可以使用GQLAlchemy

安装了GQLAlchemy后,您可以使用ParquetLocalFileSystemImporter类从Parquet文件中导入数据。以下是一个示例:

from gqlalchemy import Memgraph
from gqlalchemy.transformations.importing.loaders import ParquetLocalFileSystemImporter

# 定义您的数据配置对象(parsed_yaml)
# ...

# 创建一个导入器对象
importer = ParquetLocalFileSystemImporter(
    path="path/to/your/parquet/file",
    data_configuration=parsed_yaml,
    memgraph=Memgraph()
)

# 导入数据
importer.import_data()

更多详细信息请参见https://memgraph.com/docs/gqlalchemy/how-to-guides/table-to-graph-importer。

英文:

Memgraph supports Parquet file formats via the PyArrow package. To import data from a Parquet file into Memgraph, you can use GQLAlchemy.

Once you have GQLAlchemy installed, you can use the ParquetLocalFileSystemImporter class to import data from a Parquet file. Here's an example:

from gqlalchemy import Memgraph
from gqlalchemy.transformations.importing.loaders import ParquetLocalFileSystemImporter

# Define your data configuration object (parsed_yaml)
# ...

# Create an importer object
importer = ParquetLocalFileSystemImporter(
    path="path/to/your/parquet/file",
    data_configuration=parsed_yaml,
    memgraph=Memgraph()
)

# Import the data
importer.import_data()

You can find more details at https://memgraph.com/docs/gqlalchemy/how-to-guides/table-to-graph-importer.

huangapple
  • 本文由 发表于 2023年5月10日 21:58:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76219316.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定