文档首页 > > 开发指南> 教程:使用GDS从远端服务器导入数据> 步骤2:准备源数据

步骤2:准备源数据

分享
更新时间: 2019/06/24 09:14

DWS支持将存在远端服务器上的TEXT、CSV和FIXED格式的数据导入到集群中。本教程以CSV格式的数据为例进行演示。其他两种格式,方法相同,只在外表的相关参数项设置上有差异,详细请参见使用GDS从远端服务器导入数据

准备数据源文件

为了演示如何导入多个文件,此教程使用如下3个CSV格式的数据文件作为示例进行讲解。在实际场景中,数据源文件通常是从其他数据库导出的。此教程出于操作的便利性,手动生成对应的CSV格式数据源文件。

此样例数据与“教程:从OBS导入数据到集群”中的相同,如果您依然保有实施OBS导入教程的样例数据,可以直接拿来上传到数据服务器中。

  • 数据文件“product_info0.csv”

    示例数据如下所示:

    100,XHDK-A,2017-09-01,A,2017 Shirt Women,red,M,328,2017-09-04,715,good!
    205,KDKE-B,2017-09-01,A,2017 T-shirt Women,pink,L,584,2017-09-05,40,very good!
    300,JODL-X,2017-09-01,A,2017 T-shirt men,red,XL,15,2017-09-03,502,Bad.
    310,QQPX-R,2017-09-02,B,2017 jacket women,red,L,411,2017-09-05,436,It's nice.
    150,ABEF-C,2017-09-03,B,2017 Jeans Women,blue,M,123,2017-09-06,120,good.
  • 数据文件“product_info1.csv”

    示例数据如下所示:

    200,BCQP-E,2017-09-04,B,2017 casual pants men,black,L,997,2017-09-10,301,good quality.
    250,EABE-D,2017-09-10,A,2017 dress women,black,S,841,2017-09-15,299,This dress fits well.
    108,CDXK-F,2017-09-11,A,2017 dress women,red,M,85,2017-09-14,22,It's really amazing to buy.
    450,MMCE-H,2017-09-11,A,2017 jacket women,white,M,114,2017-09-14,22,very good.
    260,OCDA-G,2017-09-12,B,2017 woolen coat women,red,L,2004,2017-09-15,826,Very comfortable.
  • 数据文件“product_info2.csv”

    示例数据如下所示:

    980,"ZKDS-J",2017-09-13,"B","2017 Women's Cotton Clothing","red","M",112,,,
    98,"FKQB-I",2017-09-15,"B","2017 new shoes men","red","M",4345,2017-09-18,5473
    50,"DMQY-K",2017-09-21,"A","2017 pants men","red","37",28,2017-09-25,58,"good","good","good"
    80,"GKLW-l",2017-09-22,"A","2017 Jeans Men","red","39",58,2017-09-25,72,"Very comfortable."
    30,"HWEC-L",2017-09-23,"A","2017 shoes women","red","M",403,2017-09-26,607,"good!"
    40,"IQPD-M",2017-09-24,"B","2017 new pants Women","red","M",35,2017-09-27,52,"very good."
    50,"LPEC-N",2017-09-25,"B","2017 dress Women","red","M",29,2017-09-28,47,"not good at all."
    60,"NQAB-O",2017-09-26,"B","2017 jacket women","red","S",69,2017-09-29,70,"It's beautiful."
    70,"HWNB-P",2017-09-27,"B","2017 jacket women","red","L",30,2017-09-30,55,"I like it so much"
    80,"JKHU-Q",2017-09-29,"C","2017 T-shirt","red","M",90,2017-10-02,82,"very good."

CSV(Comma Separated Values),逗号分隔值。.csv类似于.txt、.doc等,是一种文件格式。也可理解成是一种特殊格式的纯文本文件。文件内容由记录组成,每条记录被逗号或制表符(Tab)分隔为字段,且每条记录都有同样的字段序列。在Windows系统环境下.csv文件打开方式有多种,如记事本、Excel、Notepad++等。

以下是Windows下生成.csv文件的办法:

  1. 新建文本文档并使用notepad++打开后,将示例数据拷贝进文本文档中。注意拷贝后检查下数据的行数及数据分行的正确性。
  2. 选择“格式>以UTF-8无BOM格式编码”。
  3. 选择“文件>另存为”。
  4. 在弹出的对话框中输入文件名后,单击“保存”。

    出于标识的目的,输入文件名的时候,建议将文件后缀设为.csv。

将数据源文件上传至数据服务器

  1. 以root用户登录用于存放数据源文件的服务器(又称数据服务器或GDS服务器)192.168.0.90。
  2. 创建数据文件存放目录“/input_data”。

    mkdir -p /input_data

  3. 使用MobaXterm将数据源文件上传至上一步所创建的目录中。
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

跳转到云社区