2 Replies Latest reply on Sep 1, 2016 1:25 AM by bkirchner-2 RSS
    bkirchner-2 Explorer

    Date format for CSV??

    I have a csv file that I read in. The first two fields are date and time respectively.

     

    The format in the CSV file is shown below.

    1.9.2016,11:21:49.562,,,,,,,

     

    day month year, hours:minutes:seconds:milli,

     

    How do I get the GetCSVFile  dateFormat: undefined /*STRING */, to work?

     

    Some of the options I have tried....

    dateFormat: 'yyyy-MM-dd HH:mm:ss'/*STRING */,

    dateFormat: 'yyyy-MM-dd'/*STRING */,

    dateFormat: 'dd-MM-yyyy' /*STRING */,

    dateFormat: 'dd.MM.yyyy' /*STRING */,

    dateFormat: 'ddMMyyyy' /*STRING */,

     

     

    I used this as a reference for the some of my understanding of how this should work.

    SimpleDateFormat : Date Format « Data Type « Java Tutorial

    And pretty much any variation in there with different errors each time.

     

    My data shape field base type is set to DATETIME

    The only way to read the data in is to change the field base type to string. Which defeats the purpose

     

     

     

    Does anybody have any suggestions as to how I can read in these correctly?

      • Re: Date format for CSV??
        meghan Communicator

        Bryan,

         

        From what I've found testing this scenario previously is that only one date time format can be used for the parser to recognize the field as a date. You'll would probably need to surround one in quotes so it'll parse as a string, and then you could covert it back to a date in the javascript service.

         

        Meghan

          • Re: Date format for CSV??
            bkirchner-2 Explorer

            Hi,

             

            Thanks, Although that will probably work it, it limits 90% of people out there that cant write code.

            What I have decided to do is somehow (don't know yet) use a perl script to read the csv file first to replace the "." with "-" and then remove the second "," so that the first 2 fields come in as one field that can be read.

            I had to do this to add a "," at the end of the CSV file anyway as the parser doesn't like it if you don't have one.

             

            Bryan