Add Data From Excel Using

Поділитися
Вставка
  • Опубліковано 18 гру 2022
  • In this episode I'm going to show you how you can add large number of data to your Directus database using #Excel and Flows.
    Ok, let's do one more Directus Flow, well actually two flows that are going to work in conjunction with one another.
    So imagine you have a movie database type of website, and you want to add a large number of movies to it. Currently, you have those movies stored in a Google Sheets or an Excel Document. Of course, you don't wanna do that by hand, because it will take a long time to do it.
    We can use Flows for this type of scenario, we will first save our Google Sheets or Excel document to a CSV file. We are going to parse that file on the front end and create a JSON object which we will send to a Directus Webhook, that will in turn trigger our first Flow. Since we are receiving an array of objects we can create a kind of for each loop by triggering another Flow for every object in that array. That other Flow is just simply going to add the data from the object it receives to the Movie collection.
    Ok, so let's do this.
    Code used in this video
    bit.ly/3G4hW87
    You can support my work on Patreon
    / watchlearn
    Follow me on Social Media
    Github: github.com/ivandoric
    Twitter: / ivan_doric

КОМЕНТАРІ • 15

  • @ThomasFlorence
    @ThomasFlorence Рік тому +3

    Thanks

  • @anassfiqhi3517
    @anassfiqhi3517 Рік тому +3

    Please more flows

  • @IshaqKhan010
    @IshaqKhan010 Місяць тому

    sir i have payload of millions records how i can add it, which have foreign contains too, in minimum time;

  • @JoeHannouch
    @JoeHannouch 8 місяців тому +1

    Amazing, i will be doing something very similar.
    Apart from parsing in the format we want, what is the advantage of this example compared to the built in CSV importer of Directus?

    • @WatchandLearnTutorials
      @WatchandLearnTutorials  7 місяців тому

      This is just an example of what Directus can do. Of course if importing CSV makes more sense you should use that.

    • @JoeHannouch
      @JoeHannouch 6 місяців тому +2

      @@WatchandLearnTutorials Indeed, the default CSV is useful but not very flexible, doing it with Flows gives much more control and results in cleaner Excel sheets.

  • @RobertWildling
    @RobertWildling Рік тому

    Great Example, thank you very much! - Unfortunately I get a CORS error as soon as I upload the csv file. Tried to add CORS to Directus' .env file, but no changes. Do I have to change the headers in the React App? Or what do I have to do?
    I just tried "mode:'no-cors" on the fetch method, but then I get the weird console error "add-movie.jsx:34 Error: SyntaxError: Unexpected end of input (at add-movie.jsx:29:38)"

  • @greendsnow
    @greendsnow 9 місяців тому

    do we need to sanitize the data?

  • @meerzulee
    @meerzulee Рік тому +1

    How do you iterate over arrays? or the flow does it automatically?

    • @RobertWildling
      @RobertWildling Рік тому +1

      I don't know React, but isn't useEffect triggered with each element that is added to moviesList? And therefore there are 5 calls to the webhook?
      UPDATE:
      Actually it is explained at 4:05ff: When data is delivered as an array than the flow triggers the other flow on each item. Seems as if the loop is built-in to the first flow...

    • @danwahn
      @danwahn 6 місяців тому

      @@RobertWildling @WatchandLearnTutorials - I am actually doing exactly the same thing - passing an array to the 2nd flow. But it fails with 'undefined'. I tried many different JSON payloads, but it always seems to get the full array, not iterating over the array.

  • @harrishpaul7374
    @harrishpaul7374 11 місяців тому

    How to update a collection using webhook

  • @harrishpaul7374
    @harrishpaul7374 11 місяців тому

    discord