#CognitiveServices – Easy lines to convert CSV to JSON to be used on the #AnomalyDetector service

Buy Me A Coffee

Hi!

After the event “Building an Anomaly Detector System with a few or no lines of code” at MsftReactor, some people asked for the 2 lines that I used to convert a CSV file to JSON, to be used with Cognitive Services Anomaly Detector, so here they are.

Important: you need Newtonsoft.Json to build the json content.

The input CSV is part of the Machine Learning.Net sample data, and has this sample content:

Month,ProductSales
1-Jan,271
2-Jan,150.9
3-Jan,188.1
...

And as a bonus, the full console project can be downloaded from here.

https://github.com/elbruno/Blog/tree/master/20191125%20CSV%20to%20JSON%20for%20Anomaly%20Detector

This project also have a second function which creates the JSON content using simple string, without the need of Newtonsoft.Json.

Happy coding!

Greetings @ Burlingon

El Bruno

References