Loading dated files in Tableau












1














I started to use Tableau Desktop as a tool to visualise my data.
However, my data is stored in CSV files with a date format name (e.g. datasample_yyyymmdd.csv). I need to be able to load in my files as the date is changing every day.
How do I do this in Tableau?



I searched on Google for answers, but nothing clear.










share|improve this question






















  • Do you need your files aggregated for each new day or do you only want the most recent?
    – vizyourdata
    Nov 12 '18 at 17:22












  • @vizyourdata I want to use the most recent one.
    – ECode
    Nov 12 '18 at 17:35
















1














I started to use Tableau Desktop as a tool to visualise my data.
However, my data is stored in CSV files with a date format name (e.g. datasample_yyyymmdd.csv). I need to be able to load in my files as the date is changing every day.
How do I do this in Tableau?



I searched on Google for answers, but nothing clear.










share|improve this question






















  • Do you need your files aggregated for each new day or do you only want the most recent?
    – vizyourdata
    Nov 12 '18 at 17:22












  • @vizyourdata I want to use the most recent one.
    – ECode
    Nov 12 '18 at 17:35














1












1








1







I started to use Tableau Desktop as a tool to visualise my data.
However, my data is stored in CSV files with a date format name (e.g. datasample_yyyymmdd.csv). I need to be able to load in my files as the date is changing every day.
How do I do this in Tableau?



I searched on Google for answers, but nothing clear.










share|improve this question













I started to use Tableau Desktop as a tool to visualise my data.
However, my data is stored in CSV files with a date format name (e.g. datasample_yyyymmdd.csv). I need to be able to load in my files as the date is changing every day.
How do I do this in Tableau?



I searched on Google for answers, but nothing clear.







csv load tableau tableau-public






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 15:06









ECode

4518




4518












  • Do you need your files aggregated for each new day or do you only want the most recent?
    – vizyourdata
    Nov 12 '18 at 17:22












  • @vizyourdata I want to use the most recent one.
    – ECode
    Nov 12 '18 at 17:35


















  • Do you need your files aggregated for each new day or do you only want the most recent?
    – vizyourdata
    Nov 12 '18 at 17:22












  • @vizyourdata I want to use the most recent one.
    – ECode
    Nov 12 '18 at 17:35
















Do you need your files aggregated for each new day or do you only want the most recent?
– vizyourdata
Nov 12 '18 at 17:22






Do you need your files aggregated for each new day or do you only want the most recent?
– vizyourdata
Nov 12 '18 at 17:22














@vizyourdata I want to use the most recent one.
– ECode
Nov 12 '18 at 17:35




@vizyourdata I want to use the most recent one.
– ECode
Nov 12 '18 at 17:35












2 Answers
2






active

oldest

votes


















3














This can be done with Tableau alone if your data is not extremely huge.




  1. Create a union in your csv connection, select the type as Wildcard and enter the pattern.
    enter image description here


  2. Create a data source/extract filter to keep only Top 1 path. (Extract recommended)
    enter image description here


  3. Final Result (Here 20181111 is the latest file)
    enter image description here



PS: For some date formats, TOP 1 of max may not return the correct result. In that case, create a calculated date field from filename and apply TOP1 filter based on that.






share|improve this answer























  • Cool! I hadn't seen this before. Which version are you running?
    – vizyourdata
    Nov 12 '18 at 22:14










  • @vizyourdata, 2018.2, but I remember using this even in 10.0. Please note that for some date formats, you might need to convert it to a date before applying the TOP filter as max may not interpret it correctly.
    – Jose Cherian
    Nov 12 '18 at 23:26



















2














This is something that can be done outside of Tableau in a batch command or python script. Both can be automated with Windows scheduler if on Windows. Ultimately, you want to pick up the most recent file and copy it to something like datasample_today.csv then connect Tableau to that file. Tableau will then always be connected to the latest file. Here is how you could do it in Python.



Python:



import glob
import os

list_of_files = glob.glob('/path/to/folder/*.csv') #* is wildcard
latest_file = max(list_of_files, key=os.path.getctime)
print(latest_file)

from shutil import copyfile

copyfile(latest_file, '<your dir>datasample_today.csv')


I'm not at all proficient in batch commands so you'll have to test this out and there is a lot here on SO to help.



Batch:



FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264937%2floading-dated-files-in-tableau%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    This can be done with Tableau alone if your data is not extremely huge.




    1. Create a union in your csv connection, select the type as Wildcard and enter the pattern.
      enter image description here


    2. Create a data source/extract filter to keep only Top 1 path. (Extract recommended)
      enter image description here


    3. Final Result (Here 20181111 is the latest file)
      enter image description here



    PS: For some date formats, TOP 1 of max may not return the correct result. In that case, create a calculated date field from filename and apply TOP1 filter based on that.






    share|improve this answer























    • Cool! I hadn't seen this before. Which version are you running?
      – vizyourdata
      Nov 12 '18 at 22:14










    • @vizyourdata, 2018.2, but I remember using this even in 10.0. Please note that for some date formats, you might need to convert it to a date before applying the TOP filter as max may not interpret it correctly.
      – Jose Cherian
      Nov 12 '18 at 23:26
















    3














    This can be done with Tableau alone if your data is not extremely huge.




    1. Create a union in your csv connection, select the type as Wildcard and enter the pattern.
      enter image description here


    2. Create a data source/extract filter to keep only Top 1 path. (Extract recommended)
      enter image description here


    3. Final Result (Here 20181111 is the latest file)
      enter image description here



    PS: For some date formats, TOP 1 of max may not return the correct result. In that case, create a calculated date field from filename and apply TOP1 filter based on that.






    share|improve this answer























    • Cool! I hadn't seen this before. Which version are you running?
      – vizyourdata
      Nov 12 '18 at 22:14










    • @vizyourdata, 2018.2, but I remember using this even in 10.0. Please note that for some date formats, you might need to convert it to a date before applying the TOP filter as max may not interpret it correctly.
      – Jose Cherian
      Nov 12 '18 at 23:26














    3












    3








    3






    This can be done with Tableau alone if your data is not extremely huge.




    1. Create a union in your csv connection, select the type as Wildcard and enter the pattern.
      enter image description here


    2. Create a data source/extract filter to keep only Top 1 path. (Extract recommended)
      enter image description here


    3. Final Result (Here 20181111 is the latest file)
      enter image description here



    PS: For some date formats, TOP 1 of max may not return the correct result. In that case, create a calculated date field from filename and apply TOP1 filter based on that.






    share|improve this answer














    This can be done with Tableau alone if your data is not extremely huge.




    1. Create a union in your csv connection, select the type as Wildcard and enter the pattern.
      enter image description here


    2. Create a data source/extract filter to keep only Top 1 path. (Extract recommended)
      enter image description here


    3. Final Result (Here 20181111 is the latest file)
      enter image description here



    PS: For some date formats, TOP 1 of max may not return the correct result. In that case, create a calculated date field from filename and apply TOP1 filter based on that.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 12 '18 at 23:29

























    answered Nov 12 '18 at 21:46









    Jose Cherian

    3,15812227




    3,15812227












    • Cool! I hadn't seen this before. Which version are you running?
      – vizyourdata
      Nov 12 '18 at 22:14










    • @vizyourdata, 2018.2, but I remember using this even in 10.0. Please note that for some date formats, you might need to convert it to a date before applying the TOP filter as max may not interpret it correctly.
      – Jose Cherian
      Nov 12 '18 at 23:26


















    • Cool! I hadn't seen this before. Which version are you running?
      – vizyourdata
      Nov 12 '18 at 22:14










    • @vizyourdata, 2018.2, but I remember using this even in 10.0. Please note that for some date formats, you might need to convert it to a date before applying the TOP filter as max may not interpret it correctly.
      – Jose Cherian
      Nov 12 '18 at 23:26
















    Cool! I hadn't seen this before. Which version are you running?
    – vizyourdata
    Nov 12 '18 at 22:14




    Cool! I hadn't seen this before. Which version are you running?
    – vizyourdata
    Nov 12 '18 at 22:14












    @vizyourdata, 2018.2, but I remember using this even in 10.0. Please note that for some date formats, you might need to convert it to a date before applying the TOP filter as max may not interpret it correctly.
    – Jose Cherian
    Nov 12 '18 at 23:26




    @vizyourdata, 2018.2, but I remember using this even in 10.0. Please note that for some date formats, you might need to convert it to a date before applying the TOP filter as max may not interpret it correctly.
    – Jose Cherian
    Nov 12 '18 at 23:26













    2














    This is something that can be done outside of Tableau in a batch command or python script. Both can be automated with Windows scheduler if on Windows. Ultimately, you want to pick up the most recent file and copy it to something like datasample_today.csv then connect Tableau to that file. Tableau will then always be connected to the latest file. Here is how you could do it in Python.



    Python:



    import glob
    import os

    list_of_files = glob.glob('/path/to/folder/*.csv') #* is wildcard
    latest_file = max(list_of_files, key=os.path.getctime)
    print(latest_file)

    from shutil import copyfile

    copyfile(latest_file, '<your dir>datasample_today.csv')


    I'm not at all proficient in batch commands so you'll have to test this out and there is a lot here on SO to help.



    Batch:



    FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT





    share|improve this answer




























      2














      This is something that can be done outside of Tableau in a batch command or python script. Both can be automated with Windows scheduler if on Windows. Ultimately, you want to pick up the most recent file and copy it to something like datasample_today.csv then connect Tableau to that file. Tableau will then always be connected to the latest file. Here is how you could do it in Python.



      Python:



      import glob
      import os

      list_of_files = glob.glob('/path/to/folder/*.csv') #* is wildcard
      latest_file = max(list_of_files, key=os.path.getctime)
      print(latest_file)

      from shutil import copyfile

      copyfile(latest_file, '<your dir>datasample_today.csv')


      I'm not at all proficient in batch commands so you'll have to test this out and there is a lot here on SO to help.



      Batch:



      FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT





      share|improve this answer


























        2












        2








        2






        This is something that can be done outside of Tableau in a batch command or python script. Both can be automated with Windows scheduler if on Windows. Ultimately, you want to pick up the most recent file and copy it to something like datasample_today.csv then connect Tableau to that file. Tableau will then always be connected to the latest file. Here is how you could do it in Python.



        Python:



        import glob
        import os

        list_of_files = glob.glob('/path/to/folder/*.csv') #* is wildcard
        latest_file = max(list_of_files, key=os.path.getctime)
        print(latest_file)

        from shutil import copyfile

        copyfile(latest_file, '<your dir>datasample_today.csv')


        I'm not at all proficient in batch commands so you'll have to test this out and there is a lot here on SO to help.



        Batch:



        FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT





        share|improve this answer














        This is something that can be done outside of Tableau in a batch command or python script. Both can be automated with Windows scheduler if on Windows. Ultimately, you want to pick up the most recent file and copy it to something like datasample_today.csv then connect Tableau to that file. Tableau will then always be connected to the latest file. Here is how you could do it in Python.



        Python:



        import glob
        import os

        list_of_files = glob.glob('/path/to/folder/*.csv') #* is wildcard
        latest_file = max(list_of_files, key=os.path.getctime)
        print(latest_file)

        from shutil import copyfile

        copyfile(latest_file, '<your dir>datasample_today.csv')


        I'm not at all proficient in batch commands so you'll have to test this out and there is a lot here on SO to help.



        Batch:



        FOR /F %%I IN ('DIR *.* /B /O:-D') DO COPY %%I <<NewDir>> & EXIT






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 12 '18 at 22:17

























        answered Nov 12 '18 at 19:25









        vizyourdata

        57411031




        57411031






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264937%2floading-dated-files-in-tableau%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma