cs-icon.svg

Export Content to .CSV File | Old Commands

The cm:export-to-csv command allows users to export the following data into a CSV file:

This makes it easy for users to perform other operations such as create content backups, perform data analysis, and so on.

To export the content of a stack, you need to have access to it. Likewise, to export an organization’s user data, you need to be the “owner” or an “admin” user of that organization.

You can export content into a .csv file by performing the following two steps:

  1. Log in to the CLI session
  2. Use the “cm:export-to-csv” command

Prerequisites

  1. Log in to the CLI Session

    Note: By default, the CLI session uses the North American region. To set the European or Azure North Amercian region, refer to the Set Region command for more details.

    You will need an authtoken to use the export-to-csv command. To generate the authtoken, open your terminal, and run the following command to log in to your Contentstack account:

    csdx auth:login
    

    It will ask you to provide your email address and password of your Contentstack account. Once you log in successfully, an authtoken will be generated and saved to the CLI session until you log out from this session.

    Additional Resource: To learn more about the login command, refer to the Login command section.

    login.png


  2. Use the ‘cm:export-to-csv’ command

    Now that you are logged in to Contentstack, let’s export content from the source stack in a CSV file by running the following command in your terminal:

    csdx cm:export-to-csv
    

    This command will prompt the following options as follows:

    • Export entries to CSV: Export all entries of a stack to a CSV file. You should have access to the stack.
      This option will ask you to select the following:
      • Organization where your stack resides 
      • Stack where the content type resides
      • Content type(s) to which the entries belong
      • Language of which you want to export the entries
    • Export organization users to CSV: Export the organization users’ details to a CSV file. To use this option, you should either be an Organization Owner or the Organization Admin. This option lists the organization(s) of which you are either an owner or admin.
    • Exit: Stop this command from further execution.

    Once you select any one of the above-mentioned options, the “data” folder is auto-generated in the current working directory (folder), and the corresponding CSV files are stored within this “data” folder.

Was this article helpful?
^