Question

How to reference and extract date and time from CSV cell to populate new data columns

  • 18 April 2022
  • 6 replies
  • 13 views

Badge +4

I am reading in a CSV file. I need to reference the first cell (Column MA and row 1) and extract the date and time from this cell, and use these two values to populate two new columns - Date and Time, and add these two new columns to my output along with existing columns such as MA, 1, 2, 3 from current CSV files. I like to get hep on how to reference and extra the cell value, and then add the two columns through AttributeManager or AttributeCreator. Thanks in advance for your help.


6 replies

Userlevel 4
Badge +30

Hi @jhu_20​ 

 

Please, could you share your data?

 

Thanks in Advance,

Danilo

Badge +4

Danilo,

Thanks for your message. Please see attached sample data which I need to extract date and time from the CSV row1 and column1 cell, and add as two new columns with date and time values. Please help.

Badge +4

Sample file

Userlevel 4
Badge +30

Sample file

Thanks!

Userlevel 4
Badge +30

Hi @jhu_20​ 

 

For your case - I used the transformer StringSearcher:

 

StringSearcher 

In the both transformers, I used regular expression to find: Date and Time. As you can see the Workspace attached, it was created list of attributes:

 

Result 

Attached the Workspace.

 

Thanks in Advance,

Danilo

 

 

Badge +4

Danilo,

Thanks for your suggestion. Since this is always in the cell of first row and first column for all CSV file (daily storm forecast data), is any way I can just reference the cell somehow and extract the date and time value ? In the mean time, I will look into your suggestion in more detail. Thanks.

Reply