官术网_书友最值得收藏!

Recursion and Parameters

Importing files one at a time is time-consuming, especially if you have many files in a folder that need to be imported. A simple solution is to use a recursive procedure. A recursive procedure is one that can call itself and saves you, the user, from entering the same import command for each file.

Performing a recursive CLI command requires passing a parameter to the API. This sounds complicated, but it is incredibly easy. First, a parameter is simply a name or option that is passed to a program to affect the operation of the receiving program. In our case, the parameter is recursive, and the entire command to perform the recursive command is as follows:

aws s3 cp s3://myBucket . --recursive

With this command, all the S3 objects in the bucket are copied to the specified directory:

Figure 1.33: Parameter list

Activity 1.01: Putting the Data into S3 with the CLI

Let's start with a note about the terminology used in this activity. Putting data into S3 can also be called uploading. Getting it from there is called downloading. Sometimes, it is also called importing and exporting. Please do not confuse this with AWS Import/Export, which is a specific AWS service for sending a large amount of data to AWS or getting it back from AWS.

In this activity, we will be using the CLI to create a bucket in S3 and import a second text file. Suppose that you are creating a chatbot. You have identified text documents that contain content that will allow your chatbot to interact with customers more effectively. Before the text documents can be parsed, they need to be uploaded to an S3 bucket. Once they are in S3, further analysis will be possible. To ensure that this has happened correctly, you will need to install Python, set up the Amazon CLI tools, and have a user authenticated with the CLI:

  1. Configure the CLI and verify that it can successfully connect to your AWS environment.
  2. Create a new S3 bucket.
  3. Import your text file into the bucket.
  4. Export the file from the bucket and verify the exported objects.

    Note

    The solution for this activity can be found on page 276.

主站蜘蛛池模板: 白河县| 东至县| 东乡县| 利川市| 湘潭市| 射阳县| 凤翔县| 南昌县| 吉木萨尔县| 高尔夫| 喜德县| 巴彦淖尔市| 通江县| 车险| 滕州市| 富锦市| 赤壁市| 阜平县| 岳西县| 临夏县| 乌兰察布市| 太仆寺旗| 天门市| 绵阳市| 福泉市| 色达县| 舒兰市| 扎鲁特旗| 邵武市| 德化县| 内丘县| 曲阳县| 平陆县| 元江| 岳阳县| 井陉县| 麟游县| 上林县| 肇庆市| 锡林浩特市| 府谷县|