Exemplo n.º 1
0
        public static string CrreateJson(BlobDataContract blob)
        {
            var limit = 0;
            var js    = string.Empty;

            js += "[{";
            js += $"\"user_anon_id\": \"{blob.user_anon_id}\",";
            js += $"\"client_CountryOrRegion\": \"{blob.client_CountryOrRegion}\",";
            js += $"\"client_StateOrProvince\": \"{blob.client_StateOrProvince}\",";
            js += $"\"client_City\": \"{blob.client_City}\",";
            js += $"\"client_OS\": \"{blob.client_OS}\",";
            js += $"\"client_Model\": \"{blob.client_Model}\",";
            js += $"\"client_Browser\": \"{blob.client_Browser}\",";
            js += $"\"session_landing_page_vector\": {blob.session_landing_page_vector},"; // array
            js += $"\"session_daytime_vector\": {blob.session_daytime_vector},";           //array
            js += $"\"session_weekend\": {blob.session_weekend},";
            js += $"\"n_session\": {blob.n_session},";
            js += $"\"session_length_mean\": {blob.session_length_mean},";
            js += $"\"session_length_std\": {blob.session_length_std},";
            js += $"\"session_length_sum\": {blob.session_length_sum},";
            js += $"\"game_session_daytime_vector\": {blob.game_session_daytime_vector},";// array
            js += $"\"n_game_session\": {blob.n_game_session},";
            js += $"\"game_session_weekend\": {blob.game_session_weekend},";
            js += $"\"game_session_length_mean\": {blob.game_session_length_mean},";
            js += $"\"game_session_length_std\": {blob.game_session_length_std},";
            js += $"\"game_session_length_sum\": {blob.game_session_length_sum},";
            js += $"\"game_completion_rate\": {blob.game_completion_rate},";
            js += $"\"game_category_vector\": {blob.game_category_vector},";                                  //array
            js += $"\"user_game_vector\": {blob.user_game_vector.Remove(blob.user_game_vector.Length - 1)},"; //array
            js += $"\"timestamp\":\"{DateTime.Now:o}\"";
            js += "}]";
            limit++;
            return(js);
        }
Exemplo n.º 2
0
        public static List <BlobDataContract> ReadCsv(string path)
        {
            if (path == "Path to Csv DataBase")
            {
                path = @"D:\users_2019-04-23.csv";
            }
            var csvList = new List <BlobDataContract>();

            using (var reader = new StreamReader(path))
            {
                while (!reader.EndOfStream)
                {
                    var line        = reader.ReadLine();
                    var values      = line.Split(new [] { "\",\"" }, StringSplitOptions.None);
                    var blobElement = new BlobDataContract
                    {
                        user_anon_id           = values[0].Replace("\"\"", "").Replace("\"", ""),
                        client_CountryOrRegion = values[1],
                        client_StateOrProvince = values[2],
                        client_City            = values[3],
                        client_OS      = values[4],
                        client_Model   = values[5],
                        client_Browser = values[6],
                        session_landing_page_vector = values[7],
                        session_daytime_vector      = values[8],
                        session_weekend             = values[9],
                        n_session                   = values[10],
                        session_length_mean         = values[11],
                        session_length_std          = values[12],
                        session_length_sum          = values[13],
                        game_session_daytime_vector = values[14],
                        user_game_vector            = values[22].Replace("\"\"", "\""),
                        n_game_session              = values[15],
                        game_session_weekend        = values[16],
                        game_session_length_mean    = values[17],
                        game_session_length_std     = values[18],
                        game_session_length_sum     = values[19],
                        game_completion_rate        = values[20],
                        game_category_vector        = values[21],
                    };
                    if (blobElement.n_session == "n_session")
                    {
                        continue;
                    }
                    csvList.Add(blobElement);
                }
            }

            return(csvList);
        }