This message was deleted.
# help
s
This message was deleted.
a
All data that are read in from CSV are initially interpreted as string values. How are you r dates formatted in the original CSV? If they are formatted in the same way as the source data in the notebook, everything should work. If not you may have to do some tinkering to get the dates working correct. Can you share your progress and attempts as a notebook?
m
Sure. The first notebook shows one where the data randomly works. The second notebook shows a non-working example of where I updated the same data by adding more data and then proceeded to monkey around with the date format for what seems like hours and hours due to the error I was receiving. Any insight would truly be appreciated. I am falling in love with this stuff and excited to push past the rookie mistakes at some point. Thanks again!
a
@Matthew If you parse the date field when you import the csv, it fixes the problem:
Copy code
dji = (await FileAttachment("^DJI-3@3.csv").csv({typed: true})).map(d => {
  const {date, ...row} = d // split date out from the rest of the row
  return {date: new Date(date), ...row} // rebuild with the date parsed as a date
})
Likewise, if you load the csv into the data table, you can use the data table name as the source for the calendar charts as well - the date is pre-parsed when imported to the table…
m
@Adam Roberts Thank you for this. I appreciate it. I had actually found this article yesterday while looking for a solution. I think I was on the right track but being a noob makes everything take way longer. Especially when you don't know exactly what the problem is that you are trying to solve. You seemed to know precisely what to do. Whereas, I played with the new Date() and getUTCFullYear for at least two days with no luck. Is that just a time/experience thing or do you have some insight for me to learn from? I assume just playing around consistently like I am right now and time is going to be the most beneficial. Thank you again. Very much. Cheers! -M@
a
Dates are always a bit tricker than I want them to be - it’s not you! In my case I just recognized that the error was from the calendar’s attempt to invoke a date method, but the source data was still a string (as @aaronkyle pointed out). Keep playing and keep asking questions - it’s the best way to learn!