英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论