1

When importing a CSV file containing live market data to DolphinDB, how to convert the time columns to the DolphinDB TIME type time in DolphinDB? For example, the csv file contains a time value 093000000 which will be parsed as a string if I import the file with loadText. How can I convert it to 09:30:00.000, the TIME data type?

Eva Gao
  • 402
  • 1
  • 7

1 Answers1

0

If you have imported the data into DolphinDB, use temporalParse to convert strings to temporal types in DolphinDB.

temporalParse( "093000000", "HHmmssSSS")

If you haven't yet imported the CSV file, use loadText. Use the schema parameter to specify the time format of the temporal column. Check the code sample below:

schema = extractTextSchema("yourFilePath");
update schema set type="TIME" where name = "yourTimeColumnName"  //modify the data type of a specified column
update schema set format=""  // Add a format column to the variable schema
update schema set format="HHmmssSSS" where name = "yourTimeColumnName" // Modify the time format of the specified TIME column
loadText("yourFilePath",,schema)
Polly
  • 603
  • 3
  • 13