cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Date format for CSV??

BryanK
16-Pearl

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?

ACCEPTED SOLUTION

Accepted Solutions
mhollenbach
12-Amethyst
(To:BryanK)

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

View solution in original post

2 REPLIES 2
mhollenbach
12-Amethyst
(To:BryanK)

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

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

Announcements


Top Tags